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
 [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: Mon Dec 30 14:01:28 2024 UTC