rfc:class_name_literal_on_object
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision |
rfc:class_name_literal_on_object [2020/01/09 19:57] – nikic | rfc:class_name_literal_on_object [2020/02/17 10:51] (current) – nikic |
---|
* Author: Nikita Popov <nikic@php.net> | * Author: Nikita Popov <nikic@php.net> |
* Target Version: PHP 8.0 | * Target Version: PHP 8.0 |
* Status: Under Discussion | * Status: Implemented |
* Implementation: https://github.com/php/php-src/pull/5065 | * Implementation: https://github.com/php/php-src/pull/5065 |
| |
</PHP> | </PHP> |
| |
**Open Question:** Additionally, it would be possible to also allow ''$object'' to be string, in which case the string would be returned verbatim. This would be consistent with the ''$className::CONST_NAME'' syntax. I'm not sure whether we should do that, as I can't imagine a context in which this would be useful, and the fact that the class name is not validated or loaded might be more unexpected here than usual. | This RFC does not permit ''$object'' to be a string and throws a ''TypeError'' in that case as well. It would be possible to allow strings to be consistent with the ''$className::CONST_NAME'' syntax. In that case, ''$str::class'' would return ''$str'' verbatim. As this doesn't seem practically useful, and likely somewhat surprising (esp. the fact that the class name is not validated at all, and can contain characters not allowed in class names), this functionality is omitted. |
| |
===== Backward Incompatible Changes ===== | ===== Backward Incompatible Changes ===== |
===== Vote ===== | ===== Vote ===== |
| |
Yes/No. | Voting started 2020-01-28 and ends 2020-02-11. |
| |
| <doodle title="Allow ::class on objects?" auth="nikic" voteType="single" closed="true"> |
| * Yes |
| * No |
| </doodle> |
| |
rfc/class_name_literal_on_object.txt · Last modified: 2020/02/17 10:51 by nikic