From: andrea at 3site dot it Operating system: Windows XP PHP version: 5.2.6RC3 PHP Bug Type: Feature/Change Request Bug description: class name as defined constant
Description: ------------ It seems to be an ambiguity issue and a probable future problem. You can create a class and define a constant with the same name and vice-versa. Who is the class and who is the constant? For future problems: currently, the magic __toString method works as magic instance method even if it is declared as public static ( ... and inherited in instances as public without static ... but this is another problem ... ) If one day PHP would like to support a public static __toString method this ambiguity will be a problem to understand if we are trying to get them, or the possible defined constant. Reproduce code: --------------- class Test{} define('Test', 123); // defined('Test') or class_exists('Test') ? define('Test2', 'Test2'); class Test2{} get_class(new Test2) === Test2; // true echo Test2; // Test2 $ref = Test2; new $ref; // an instanceof Test2 ... is_string(Test2); // true Expected result: ---------------- A fatal error, because a constant should be a unique and immutable value with a name that could not be used as class one and a class should be unique as well (if we cannot use the same name for two different classes, how can we have two totally different meaning with a sngle name, the class and the constant) Actual result: -------------- It is possible to create a class and then define a constant with the same name, and it is possible to define a constant and then a class with the same name. -- Edit bug report at http://bugs.php.net/?id=44568&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=44568&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=44568&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=44568&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=44568&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=44568&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=44568&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=44568&r=needscript Try newer version: http://bugs.php.net/fix.php?id=44568&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=44568&r=support Expected behavior: http://bugs.php.net/fix.php?id=44568&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=44568&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=44568&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=44568&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=44568&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=44568&r=dst IIS Stability: http://bugs.php.net/fix.php?id=44568&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=44568&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=44568&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=44568&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=44568&r=mysqlcfg