Bug #67007 [Opn->Ver]: Incorrect (inaccurate) PHP Notice regarding the use of constants
| From: | yohgaki@php.net | Date: | Sun, 06 Jul 2014 01:39:52 +0000 |
| Subject: | Bug #67007 [Opn->Ver]: Incorrect (inaccurate) PHP Notice regarding the use of constants | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-186480@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: yohgaki@php.net
Reported by: edvinas at pnd dot io
Summary: Incorrect (inaccurate) PHP Notice regarding the use
of constants
-Status: Open
+Status: Verified
Type: Bug
Package: *General Issues
Operating System: Linux
PHP Version: 5.5.10
Block user comment: N
Private report: N
Previous Comments:
------------------------------------------------------------------------
[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