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-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 you forgot your password, you can retrieve your password here.
Password:
Status:
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

Pull Requests

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
 [2020-03-01 22:21 UTC] cmb@php.net
-Status: Assigned +Status: Closed
 [2020-03-01 22:21 UTC] cmb@php.net
<https://wiki.php.net/rfc/class_name_literal_on_object>
has already been implemented. :)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 14:01:30 2024 UTC