Consts in an interface

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Paw
Forum Newbie
Posts: 20
Joined: Tue Jul 17, 2007 10:27 am

Consts in an interface

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
Paw
Forum Newbie
Posts: 20
Joined: Tue Jul 17, 2007 10:27 am

Post 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 :-)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
Post Reply