Bug #67007 [NEW]: Incorrect (inaccurate) PHP Notice regarding the use of constants

From: Date: Wed, 02 Apr 2014 11:38:32 +0000
Subject: Bug #67007 [NEW]: Incorrect (inaccurate) PHP Notice regarding the use of constants
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-185033@lists.php.net to get a copy of this message
From: edvinas at pnd dot io Operating system: Linux PHP version: 5.5.10 Package: *General Issues Bug Type: Bug Bug description:Incorrect (inaccurate) PHP Notice regarding the use of constants Description: ------------ PHP provides inaccurate NOTICE message regarding constants on class initialization. When you initialize new class, the error message does not point the line in the class which causes said error message, but points to a line where Class is initialized instead. Test script: --------------- // Foo.php <?php class Foo { const BAR = 1; protected $message = BAR; // <- this line is intentionally incorrect public function __construct($message) { $this->message = $message; echo "Initialized with {$this->message}"; } } // test.php <?php include 'Foo.php'; $var = new Foo(Foo::BAR); Expected result: ---------------- Expected result: Notice: Use of undefined constant BAR - assumed 'BAR' in Foo.php on line 5 Actual result: -------------- Actual result: Notice: Use of undefined constant BAR - assumed 'BAR' in test.php on line 3 -- Edit bug report at https://bugs.php.net/bug.php?id=67007&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=67007&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=67007&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=67007&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=67007&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=67007&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=67007&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=67007&r=needscript Try newer version: https://bugs.php.net/fix.php?id=67007&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=67007&r=support Expected behavior: https://bugs.php.net/fix.php?id=67007&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=67007&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=67007&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=67007&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=67007&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=67007&r=dst IIS Stability: https://bugs.php.net/fix.php?id=67007&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=67007&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=67007&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=67007&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=67007&r=mysqlcfg

« previous php.bugs (#185033) next »