ID: 39003
Comment by: judas dot iscariote at gmail dot com
Reported By: christoph at ziegenberg dot de
Status: Open
Bug Type: Performance problem
Operating System: WinXP SP2
PHP Version: 5.1.6
New Comment:
if this is the expected behaviuor ( at least, not the behaviuor I
expect ;) ) it is not mentioned in the manual, so either the manual or
the engine needs to be corrected ;-)
Previous Comments:
------------------------------------------------------------------------
[2006-09-30 10:05:56] christoph at ziegenberg dot de
Description:
------------
if i check if a variable is an instance of specific class with
"instanceof" and the class i check for has not been loaded,
__autoloader() is not called (as expected).
if i do the "same" check by type hinting, the __autoloader() function
is called, which normally leads to including the required class file
and so unnecessarily consumes memory and time.
Reproduce code:
---------------
<?php
error_reporting(E_ALL);
class ClassName
{
public $var = 'bla';
}
function test (OtherClassName $object)
{
}
function __autoload($class)
{
print "try to load class $class";
}
$obj = new ClassName;
if (!($obj instanceof OtherClassName))
{
echo "no instance of OtherClassName<br />";
}
test($obj);
?>
Expected result:
----------------
no instance of OtherClassName
Actual result:
--------------
no instance of OtherClassName
try to load class OtherClassName
Fatal error: Class 'OtherClassName' not found in [...] on line 7
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=39003&edit=1