Bug #70457 [Com]: Wrong line number for E_NOTICE - undefined constant in class
| From: | php4fan at gmail dot com | Date: | Fri, 06 Nov 2020 16:56:48 +0000 |
| Subject: | Bug #70457 [Com]: Wrong line number for E_NOTICE - undefined constant in class | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-230168@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=70457&edit=1
ID: 70457
Comment by: php4fan at gmail dot com
Reported by: daniel dot jaenecke at sedo dot com
Summary: Wrong line number for E_NOTICE - undefined constant
in class
Status: Verified
Type: Bug
Package: Scripting Engine problem
Operating System: Any
PHP Version: Any
Block user comment: N
Private report: N
New Comment:
Congratulation guys, it's been 5 years and this is still an issue.
Previous Comments:
------------------------------------------------------------------------
[2018-03-26 13:50:11] yohgaki@php.net
Oops. I thought I commented out var_dump().
const has the same issue as well.
https://3v4l.org/Gi3CO
------------------------------------------------------------------------
[2018-03-26 13:47:21] yohgaki@php.net
That's what I guessed, thanks.
Anway, since we are going to raise ERROR for undefined constants (Correct?), this delayed
"undefined constant error" could be serious problem. It may be better to document this
behavior explicitly. define() is nasty in many ways due to its dynamic nature.
http://php.net/manual/en/function.define.php
"const" works fine.
https://3v4l.org/cN5n4
------------------------------------------------------------------------
[2018-03-26 10:07:20] nikic@php.net
Nowadays delayed constants store an AST, which contains the necessary line number information. This
is still not entirely simple, as we also need a) the file name (which is available on the parent
class / function, but not inside update_constant) and b) an ability to override the source of an
error (something like CG(zend_lineno), but for runtime use).
------------------------------------------------------------------------
[2018-03-26 09:41:04] yohgaki@php.net
https://3v4l.org/ULp0K
It happens with static var.
Error line is meaningless, since "undefined constant error" is raised for
"other" static var.
It can hide "undefined constant error" with static class until code access to static var.
See 3v4l result for details.
------------------------------------------------------------------------
[2015-09-08 13:54:29] 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.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=70457
--
Edit this bug report at https://bugs.php.net/bug.php?id=70457&edit=1