Req #79085 [NEW]: Incosistency on ::class constant
| From: | almamu at almamu dot com | Date: | Wed, 08 Jan 2020 19:18:05 +0000 |
| Subject: | Req #79085 [NEW]: Incosistency on ::class constant | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-224789@lists.php.net to get a copy of this message | ||
From: almamu at almamu dot com
Operating system: Any
PHP version: 7.2.26
Package: Class/Object related
Bug Type: Feature/Change Request
Bug description:Incosistency on ::class constant
Description:
------------
I've noticed some inconsistencies on how the ::class magic constant is
handled compared to other constants/class members. As seen in the
example script, if you try to access ::class on a non-existant class,
you don't get any kind of error, which would be expected, as the class
itself doesn't exist. This can provoke some nasty errors where you typo
the class' name and PHP doesn't even give you a (expected) warning.
I've created an interactive example with that same code so you can check
it live and toy with it: https://3v4l.org/RbIhK
Test script:
---------------
<?php
echo FOO::class;
echo FOO::constantName;
echo FOO::$username; // It works as echoing Typo\WTF; It shall fail...
Expected result:
----------------
Fatal error: Uncaught Error: Class 'FOO' not found in /in/RbIhK:2
Stack trace:
#0 {main}
thrown in /in/RbIhK on line 3
Process exited with code 255.
Actual result:
--------------
FOO
Fatal error: Uncaught Error: Class 'FOO' not found in /in/RbIhK:3
Stack trace:
#0 {main}
thrown in /in/RbIhK on line 3
Process exited with code 255.
--
Edit bug report at https://bugs.php.net/bug.php?id=79085&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=79085&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=79085&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=79085&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=79085&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=79085&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=79085&r=support
Expected behavior: https://bugs.php.net/fix.php?id=79085&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=79085&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=79085&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=79085&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=79085&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=79085&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=79085&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=79085&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=79085&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=79085&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=79085&r=mysqlcfg