Req #70582 [NEW]: Referncing NotExistingClass::class should trigger error/warning/notice

From: Date: Fri, 25 Sep 2015 14:18:08 +0000
Subject: Req #70582 [NEW]: Referncing NotExistingClass::class should trigger error/warning/notice
Groups: php.standards 
Request: Send a blank email to standards-+get-859@lists.php.net to get a copy of this message
From: andreas dot stangl at stansotec dot de Operating system: Any PHP version: Next Major Version Package: PHP Language Specification Bug Type: Feature/Change Request Bug description:Referncing NotExistingClass::class should trigger error/warning/notice Description: ------------ When referencing the "magic" class constant "::class" the interpreter does not care if the given class does not exist. If I have e.g. a class "My\FancyClass" and I access the "class" constant like echo My\FancyClass::class; I get "My\FancyClass" (which is pretty cool especially for unit tests). But if e.g. My\FancyClass gets renamed to "My\FoobarClass" the interpreter will not complain at all. But referencing any other (not existing) constant of a not existing class like echo My\FoobarClass::blah; Produces a fatal error. This looks a little inconsistent to me. Test script: --------------- <?php namespace My; class FancyClass {} echo FancyClass::class . "\n"; // useful echo NotExistingClass::class . "\n"; // imho not so useful :-/ echo NotExistingClass::blah; // fatal error Expected result: ---------------- My\FancyClass PHP Fatal error: Class 'My\NotExistingClass' not found in testScript.php on line 7 Actual result: -------------- My\FancyClass My\NotExistingClass PHP Fatal error: Class 'My\NotExistingClass' not found in testScript.php on line 8 -- Edit bug report at https://bugs.php.net/bug.php?id=70582&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=70582&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=70582&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=70582&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=70582&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=70582&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=70582&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=70582&r=needscript Try newer version: https://bugs.php.net/fix.php?id=70582&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=70582&r=support Expected behavior: https://bugs.php.net/fix.php?id=70582&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=70582&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=70582&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=70582&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=70582&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=70582&r=dst IIS Stability: https://bugs.php.net/fix.php?id=70582&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=70582&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=70582&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=70582&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=70582&r=mysqlcfg

« previous php.standards (#859) next »