Req #64871 [Wfx]: The ::class operator should verify the class name
| From: | vrana@php.net | Date: | Fri, 17 May 2013 22:15:21 +0000 |
| Subject: | Req #64871 [Wfx]: The ::class operator should verify the class name | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-179001@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=64871&edit=1
ID: 64871
Updated by: vrana@php.net
Reported by: vrana@php.net
Summary: The ::class operator should verify the class name
Status: Wont fix
Type: Feature/Change Request
Package: Class/Object related
Operating System: Any
PHP Version: 5.5.0RC1
Assigned To: ralphschindler
Block user comment: N
Private report: N
New Comment:
Ralph, David is referring to https://bugs.php.net/61467. I
agree that this is not the best place for the discussion about that.
Previous Comments:
------------------------------------------------------------------------
[2013-05-17 20:13:20] ralphschindler@php.net
David,
I am not sure what behavior you're referencing. When does callable trigger autoload? Perhaps
this is a conversation for the internals mailing list?
------------------------------------------------------------------------
[2013-05-17 18:34:04] David at grudl dot com
Ralph, totally agree. What do you think about fixing type hint "callable" to not
trigger autoloading?
------------------------------------------------------------------------
[2013-05-17 18:23:40] vrana@php.net
Makes sense, thanks for the explanation.
------------------------------------------------------------------------
[2013-05-17 17:16:08] ralphschindler@php.net
I believe this came up, and I wouldn't support this. This would be inconsistent with the
current implementation of namespaces. use Foo\Bar\Baz; for example, does not check the existence of
Baz on "use". It is not not till a type is used (either statically called or used to
create a new instance of via new) that it will trigger autoloading (if there is one).
There are many places in PHP where type names are used, method signatures, and even in the following
example:
$x = new stdClass;
var_dump($x instanceof FooBar);
PHP will not attempt to autoload FooBar to for the purposes of instanceof.
If you need to know that a particular type exists, class_exists(foo::class, true); should do what
you need.
If you feel differently, I think you should bring this up on the internals mailing list.
------------------------------------------------------------------------
[2013-05-17 16:49:21] vrana@php.net
Ralph, what's your take on this?
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=64871
--
Edit this bug report at https://bugs.php.net/bug.php?id=64871&edit=1