ID:               39466
 User updated by:  kevin at metalaxe dot com
 Reported By:      kevin at metalaxe dot com
 Status:           Open
 Bug Type:         Feature/Change Request
 Operating System: *
 PHP Version:      5.2.0+
 New Comment:

"Common constants are declared in runtime using define() function,
which
is why it may take a result of an expression."

Why not expand define() to allow setting a class specific constant that
can be called as $this->class_name->some_constant ? As it stands now I
have to write excess functions that will return the values of specified
class variables. Adding the ability to add constants within the spoce of
a single class would remove that need :)


Previous Comments:
------------------------------------------------------------------------

[2007-05-18 08:18:50] kevin at metalaxe dot com

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
:)

------------------------------------------------------------------------

[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.

------------------------------------------------------------------------

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

Reply via email to