Re: [RFC] Allow ::class on objects
| From: | G. P. B. | Date: | Tue, 14 Jan 2020 18:14:25 +0000 |
| Subject: | Re: [RFC] Allow ::class on objects | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-108126@lists.php.net to get a copy of this message | ||
On Tue, 14 Jan 2020 at 19:05, Ralph Schindler <ralph@ralphschindler.com>
wrote:
>
>
> > just return $string, to be consistent with usual behavior of
> > "::CONST_NAME", which allows objects and class names on the left hand
> side.
>
> Having given it more thought, it seems like like $string::class should
> be more aligned with get_class($string), which at current throws a PHP
> Warning with the message:
>
> "PHP Warning: get_class() expects parameter 1 to be object, string
> given in ..."
>
This is going to be a TypeError in PHP 8 following the consistent type
error RFC [1]
therefore the current behaviour to throw a TypeError is inline which
get_class()
George P. Banyard
[1] https://wiki.php.net/rfc/consistent_type_errors