php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #77975 support $object::CLASS
Submitted: 2019-05-06 14:25 UTC Modified: 2020-01-08 15:36 UTC
From: Wes dot nospam at example dot org Assigned: nikic (profile)
Status: Assigned Package: Class/Object related
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: Wes dot nospam at example dot org
New email:
PHP Version: OS:

 

 [2019-05-06 14:25 UTC] Wes dot nospam at example dot org
Description:
------------
Would be great to align $object::CLASS to behave like other constants, even if CLASS isn't actually one.

The current result is:

Fatal error: Dynamic class names are not allowed in compile-time ::class fetch in

Thank you


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-05-06 14:57 UTC] requinix@php.net
-Status: Open +Status: Feedback
 [2019-05-06 14:57 UTC] requinix@php.net
Problem is that ::class is compile-time.

Why not get_class()?
 [2019-05-06 17:05 UTC] levim@php.net
Note that `static::CLASS` already works, which is somewhat dynamic. The opcode can have more arguments, I think, so I don't see any reason why this can't be done technically. What's the argument against making it support dynamic lookup?
 [2019-05-06 17:07 UTC] requinix@php.net
-Status: Feedback +Status: Open
 [2019-05-06 17:07 UTC] requinix@php.net
No argument from me - more consistency is a good thing. Just trying to understand the request in more detail.
 [2020-01-08 15:36 UTC] nikic@php.net
-Assigned To: +Assigned To: nikic
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Tue Jan 21 08:01:23 2020 UTC