Page 1 of 1
Consts in an interface
Posted: Tue Aug 07, 2007 5:33 pm
by Paw
I ran into a situation, where adding some const definitions to an interface would come in handy. I also tested it, and PHP doesn't complain. But doing so is rather unusual, and actually wrong.
However, I couldn't find a statement about this issue in the PHP manual.
So my question is: should I add consts to an interface, or could my interface break in a future release of PHP?
Posted: Tue Aug 07, 2007 5:43 pm
by feyd
It's always possible that the people behind the core could remove currently available language features, but any one feature being removed is rather unlikely. If you can't find any bug reports suggesting its removal, you should be fine for a fair bit of time.
Posted: Tue Aug 07, 2007 5:51 pm
by Paw
feyd wrote:It's always possible that the people behind the core could remove currently available language features, but any one feature being removed is rather unlikely. If you can't find any bug reports suggesting its removal, you should be fine for a fair bit of time.
Thanks for the pointer, I didn't think of the bugs database, yet. A search for "interface const" yielded following related bug ticket:
http://bugs.php.net/bug.php?id=33732
The contained discussion suggests, that consts in an interface are an intentional feature

Posted: Tue Aug 07, 2007 9:37 pm
by feyd
Paw wrote:The contained discussion suggests, that consts in an interface are an intentional feature

Then I would postulate that you may assume it will remain in the core for some time.