php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #65274 Enhance undefined class constant error with class name
Submitted: 2013-07-16 15:47 UTC Modified: 2020-01-08 13:17 UTC
Votes:3
Avg. Score:3.0 ± 1.6
Reproduced:3 of 3 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (33.3%)
From: RQuadling at GMail dot com Assigned: nikic (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5.4.17 OS: n/a
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: RQuadling at GMail dot com
New email:
PHP Version: OS:

 

 [2013-07-16 15:47 UTC] RQuadling at GMail dot com
Description:
------------
When reporting that a class constant is undefined, the error message is only half 
useful in that it doesn't say which class is missing the constant.

Whilst I can accept that the constant may be present somewhere in the class 
structure, the calling class name would aid in the error.



Test script:
---------------
<?php
class A{ const NAME = 'A valid class'; }
class B{ }

foreach(array('A','B') as $s_ClassName){
    echo $s_ClassName::NAME, PHP_EOL;
}


Expected result:
----------------
A valid class
PHP Fatal error:  Undefined class constant 'NAME' for class 'B' in - on line 6


Actual result:
--------------
A valid class
PHP Fatal error:  Undefined class constant 'NAME' in - on line 6


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-07-16 16:19 UTC] laruence@php.net
-Assigned To: +Assigned To: laruence
 [2017-10-24 08:02 UTC] kalle@php.net
-Status: Assigned +Status: Open -Assigned To: laruence +Assigned To:
 [2020-01-03 16:23 UTC] nikic@php.net
-Assigned To: +Assigned To: nikic
 [2020-01-08 13:17 UTC] nikic@php.net
-Summary: Enhance fatal error with class name. +Summary: Enhance undefined class constant error with class name
 [2020-01-08 13:18 UTC] nikic@php.net
Automatic comment on behalf of nikita.ppv@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=ae5d7604f699dac4fd824e594c7df5439a36c29b
Log: Fix #65274: Add class name to undef class constant error
 [2020-01-08 13:18 UTC] nikic@php.net
-Status: Assigned +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 03 17:01:29 2024 UTC