Bug #67547 [Com]: New feature working for undeclared classes

From: Date: Mon, 30 Jun 2014 17:25:18 +0000
Subject: Bug #67547 [Com]: New feature working for undeclared classes
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-186398@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=67547&edit=1 ID: 67547 Comment by: magnusthorek at gmail dot com Reported by: magnusthorek at gmail dot com Summary: New feature working for undeclared classes Status: Not a bug Type: Bug Package: Class/Object related Operating System: N/A PHP Version: 5.5.14 Block user comment: N Private report: N New Comment: I understood you perfectly, however this subject were raised by several different people debating about it and I would like to share this knowledge with them. So, would you mind to provide a little more elaborated version of this explanation? Previous Comments: ------------------------------------------------------------------------ [2014-06-30 17:01:31] requinix@php.net PHP doesn't actually need the definition of the class to know its fully-qualified name - all the required information is available at compile-time. So it doesn't try to load it. ------------------------------------------------------------------------ [2014-06-30 16:21:39] magnusthorek at gmail dot com Description: ------------ PHP 5.5 has implemented as a new feature a new way to retrieve the classname through the syntax ::class: It work ver well as described in "Sample #1" below. But why this syntax also returns a classname when used alongside an undeclared class, according to "Sample #2"? In several other cases an error is raised, but not here. Anyone know, with concrete basis if possible, why does this happen? Does it have anything to Late Static Bindings or it's just a (temporary) limitation/bug of this brand new feature? Test script: --------------- <?php // Sample #1 namespace Testing; class Test{} echo Test::class; // Testing\Test; ?> <?php // Sample #2 echo UndeclaredClass::class; // UndeclaredClass Expected result: ---------------- For "Sample #1": Testing\test; For Sample #2: Fatal error: Class 'UndeclaredClass'... Actual result: -------------- For "Sample #1": Testing\test; For Sample #2: UndeclaredClass ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=67547&edit=1

« previous php.bugs (#186398) next »