From: dimo dot vanchev at bianor dot com Operating system: RedHat 9.0 PHP version: 5.0.0 PHP Bug Type: Zend Engine 2 problem Bug description: PHP 5 allows class constants to be overriden
Description: ------------ If we declare a class constant twice or more PHP allows this without any notifications. This should be fixed, because it may bring to confusion. A constant should be constant, thus not allowing to be overriden neither in the same class, nor in child classes. Currently non-class constants allow to be overriden too, at least they output a notice saying "Constant already defined". Maybe this should be brought up to warning. Just my thoughts! Reproduce code: --------------- <?php class A { const MY_CONSTANT = "A. value_1"; const MY_CONSTANT = "A. value_2"; public function __construct() { echo self::MY_CONSTANT, "\n"; } } class B extends A { const MY_CONSTANT = "B. value_1"; const MY_CONSTANT = "B. value_2"; public function __construct() { echo self::MY_CONSTANT, "\n"; } } new A(); new B(); ?> Expected result: ---------------- should display warning, error or something like that. Actual result: -------------- A. value_2 B. value_2 -- Edit bug report at http://bugs.php.net/?id=29446&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=29446&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=29446&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=29446&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=29446&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=29446&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=29446&r=needscript Try newer version: http://bugs.php.net/fix.php?id=29446&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=29446&r=support Expected behavior: http://bugs.php.net/fix.php?id=29446&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=29446&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=29446&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=29446&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=29446&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=29446&r=dst IIS Stability: http://bugs.php.net/fix.php?id=29446&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=29446&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=29446&r=float