Bug #80427 [Com]: ::class keyword does not work correctly with an imported function
| From: | udaltsov dot valentin at gmail dot com | Date: | Thu, 26 Nov 2020 23:40:45 +0000 |
| Subject: | Bug #80427 [Com]: ::class keyword does not work correctly with an imported function | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-230656@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=80427&edit=1
ID: 80427
Comment by: udaltsov dot valentin at gmail dot com
Reported by: udaltsov dot valentin at gmail dot com
Summary: ::class keyword does not work correctly with an
imported function
Status: Open
Type: Bug
Package: *General Issues
PHP Version: 7.4.13
Block user comment: N
Private report: N
New Comment:
I realized what this phrase means: "The class name resolution using ::class is a compile time
transformation". So ::class just finds the used class and outputs its name regardless of
existence. That's why it doesn't work with functions â it just thinks that it's
a class in the current namespace.
Can be closed, my apologies.
P.s.: There is a relevant discussion of <function>::func syntax at https://externals.io/message/108459.
Previous Comments:
------------------------------------------------------------------------
[2020-11-26 23:13:01] udaltsov dot valentin at gmail dot com
Description:
------------
Although not documented,
class keyword can be used with constants and functions since
5.5: https://3v4l.org/FHYYd. And this is really cool.
Unfortunately, myFunction::class and MY_CONSTANT::class do not take
use function and use const into account: https://3v4l.org/Vg4tF. It's inconsistent with MyClass::class
behavior.
I suggest to fix this inconsistency.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=80427&edit=1