Bug #67007 [Ver->Dup]: Incorrect (inaccurate) PHP Notice regarding the use of constants

From: Date: Fri, 19 May 2017 10:57:45 +0000
Subject: Bug #67007 [Ver->Dup]: Incorrect (inaccurate) PHP Notice regarding the use of constants
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-209192@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=67007&edit=1 ID: 67007 Updated by: requinix@php.net Reported by: edvinas at pnd dot io Summary: Incorrect (inaccurate) PHP Notice regarding the use of constants -Status: Verified +Status: Duplicate Type: Bug -Package: *General Issues +Package: Scripting Engine problem Operating System: Linux PHP Version: 5.5.10 Block user comment: N Private report: N New Comment: Dupe-ing this one because the other has commentary. Previous Comments: ------------------------------------------------------------------------ [2017-05-19 10:41:24] jhabdas at gmail dot com Appears to be dupe of https://bugs.php.net/bug.php?id=70457 ------------------------------------------------------------------------ [2014-04-02 11:38:31] edvinas at pnd dot io 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 this bug report at https://bugs.php.net/bug.php?id=67007&edit=1

« previous php.bugs (#209192) next »