ID: 39466 User updated by: kevin at metalaxe dot com -Summary: Expaned Class constants to accept return of function value Reported By: kevin at metalaxe dot com -Status: Bogus +Status: Open Bug Type: Feature/Change Request Operating System: * PHP Version: 5.2.0+ New Comment:
I still don't know how a suggestion can be marked bogus ;) There is no reason to close it as the request is perfectly acceptable as a suggestion or feature request. If you don't want to "re-write the engine" to maintain consistency, then perhaps someone else will one day :) Previous Comments: ------------------------------------------------------------------------ [2006-11-10 23:23:33] [EMAIL PROTECTED] Again, class constants along with the classes and functions are declared in compile time, so they can have only constant value. Common constants are declared in runtime using define() function, which is why it may take a result of an expression. There is nothing to be done with that unless you're willing to rewrite all the engine from scratch. ------------------------------------------------------------------------ [2006-11-10 23:17:07] kevin at metalaxe dot com I've thought on this a bit more. It seems that php currently has the idea of constants set-up a bit limited in sight. While PHP has "constants"implimented correctly in the class scope, it doesn't implement it in this way on the global scope. It is silly that functionality of such a feature should change in such a drastic manner. If you are unwilling to change the functionality of class keyword const, then you need to implement a method as to set a variable read-only within a class. Which is just completely redundant in nature and contrary to the cause. Perhaps you could rethink how you are implementing the const keyword and revamp it to assign a member as read-only. This might even help you with implementing the visibility scopes (public, private, protected) to a class constant. Because again, it is perfectly plausible to have a constant accessible only within the scope of a single class or child classes. ------------------------------------------------------------------------ [2006-11-10 22:54:28] kevin at metalaxe dot com I don't understand why I'm being shrugged off as impossible. I'm asking for functionality similar to global constants for class constants. If you can do it for global constants, it seems only plausible that class constants should be handled in a similar fashion. I could find many more uses for the exact same functionality if necessary, within the same applicable class even. ------------------------------------------------------------------------ [2006-11-10 22:40:38] [EMAIL PROTECTED] define() is just a function. which declares constants. I was talking about class constants et al. ------------------------------------------------------------------------ [2006-11-10 22:37:11] kevin at metalaxe dot com Just for reference, I reread the docs for global constants set using define(). http://us2.php.net/manual/en/function.define.php states: Defines a named constant at runtime. See the section on constants for more details. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/39466 -- Edit this bug report at http://bugs.php.net/?id=39466&edit=1