On Mon, May 25, 2015 at 11:47 AM, Marc Bennewitz <dev@mabe.berlin> wrote: > Hi, > > I have noted that detecting a class name using "::class" it will return the > called case instead of the original case. > see http://3v4l.org/97K36 > > That's annoying as I like to check the right class case on autoload to > detect mistakes. > > Sure, class names in PHP are case-insensitive but filesystems aren't and > most autoloader using the FS to find the right file. To catch such kind of > mistakes I would like to implement a fast check in my autoloader to get > noted on development instead on production. It's currently only possible > with ReflectionClass but this will be much slower as with ::class. > > Are there any reasons to get the called case of the class instead or the > original one?
The way this is implemented means that the class doesn't even have to exist. It's purely compile-time expansion. The identifier doesn't even have to be a class at all[1]: <?php namespace foo; function bar(){} var_dump(bar::class); // string(7) "foo\bar" ?> This was not explained in the RFC at all, and had I known this I would have voted against it personally. [1] It doesn't work when you import a function name with `use function` because it's only intended to work with classes and class-like entities. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php