maettig.com

Thiemos Archiv

PHP 5.5 is weird:
use NonExistingNamespace\NonExistingClass;
$className = NonExistingClass::class;
var_dump( $className );
Result: string(37) "NonExistingNamespace\NonExistingClass". What this means: PHP does not care if the class exists. It does not care if a class mentioned in a use clause exists and it does not care if ::class is used on an existing class. A use clause does nothing but create an entry in a string map, mapping short to full qualified class names. The ::class syntax does nothing but returning a string from that map. That's all.
nice one

So PHP is still that same old thing with it's strange hammers and stuff. Even in "new" Versions that always claim to be "better"

not that surprising.
Dr. Azrael Tod
This is still much, much better than what we had before, because it's much, much easier for tools and IDEs to understand that NonExistingClass::class is meant to be a fererence to that class. This is impossible with "NonExistingNamespace\NonExistingClass".
Thiemo

Kommentare zu diesem Beitrag können per E-Mail an den Autor gesandt werden.

[ ← Zurück zur Übersicht ]

Impressum & Datenschutz