php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70457 Wrong line number for E_NOTICE - undefined constant in class
Submitted: 2015-09-08 08:46 UTC Modified: 2017-05-19 10:58 UTC
Votes:3
Avg. Score:3.7 ± 0.5
Reproduced:3 of 3 (100.0%)
Same Version:1 (33.3%)
Same OS:2 (66.7%)
From: daniel dot jaenecke at sedo dot com Assigned:
Status: Verified Package: Scripting Engine problem
PHP Version: Any OS: Any
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2015-09-08 08:46 UTC] daniel dot jaenecke at sedo dot com
Description:
------------
A notice complaining about an undefined constant assigned to a class property is reported for the wrong line number.

I could reproduce this with the provided snippet for versions 5.3, 5.5 and 5.6

Test script:
---------------
<?php

class MyClass
{

    private $var1 = ANOTHER_NONE_EXISTING_CONSTANT;
    private $var2 = 1;

}

$obj = new MyClass(); 

Expected result:
----------------
A notice for the line where the undefined constant is being used, in this case Notice: Use of undefined constant NONE_EXISTING_GLOBAL_CONSTANT […] in line 6

Actual result:
--------------
Notice: Use of undefined constant ANOTHER_NONE_EXISTING_CONSTANT - assumed 'ANOTHER_NONE_EXISTING_CONSTANT' in /home/daniel/tmp/php-linenumber-bug/code.php on line 11

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-09-08 09:20 UTC] yohgaki@php.net
-Summary: Wrong line number for E_NOTICE +Summary: Wrong line number for E_NOTICE - undefined constant in class -Package: *General Issues +Package: Scripting Engine problem -Operating System: Linux +Operating System: Any -PHP Version: 5.6.13 +PHP Version: Any
 [2015-09-08 09:20 UTC] yohgaki@php.net
https://3v4l.org/DpCPp

PHP has been emitting the error like this for a long time.
 [2015-09-08 13:54 UTC] bwoebi@php.net
We currently aren't storing any line number information for class variables/constants. And as these are only evaluated upon first use, the constant message will only appear on instantiation here.
 [2017-05-19 10:58 UTC] requinix@php.net
-Status: Open +Status: Verified
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC