On Mon, 25 May 2015 20:47:32 +0300, 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?

Marc


This happens because ::class construction is evaluated at compiled time, without triggering autoloader. That means compiler doesn't know what will be the actual name of a class, it just gives you what you asked for.

It's currently only possible with ReflectionClass but this will be much slower as with ::class.

It's only possible with ReflectionClass if this class was already loaded. There's one way for your autoloader to know if the class name has characters in a wrong case - build a class map and do a check based on this map.

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to