|  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-03-01 22:21 UTC
From: Wes dot nospam at example dot org Assigned: nikic (profile)
Status: Closed Package: Class/Object related
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
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
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


Add a Patch

Pull Requests

Add a Pull Request


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

Why not get_class()?
 [2019-05-06 17:05 UTC]
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]
-Status: Feedback +Status: Open
 [2019-05-06 17:07 UTC]
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]
-Assigned To: +Assigned To: nikic
 [2020-03-01 22:21 UTC]
-Status: Assigned +Status: Closed
 [2020-03-01 22:21 UTC]
has already been implemented. :)
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Jul 23 16:01:29 2024 UTC