ID:               43926
 Updated by:       [EMAIL PROTECTED]
 Reported By:      [EMAIL PROTECTED]
 Status:           Open
 Bug Type:         Unknown/Other Function
 Operating System: Linux
 PHP Version:      5.3CVS-2008-01-24 (CVS)
 New Comment:

.phpt: 
http://ecl.zoone.com.br/etc/patches/bug43926.phpt

Patch:
http://ecl.zoone.com.br/etc/patches/bug43926.patch


Previous Comments:
------------------------------------------------------------------------

[2008-01-24 13:16:07] [EMAIL PROTECTED]

Description:
------------
Says the documentation:

"Note: $class = new ReflectionClass('Foo'); $class->isInstance($arg) is
equivalent to $arg instanceof Foo or is_a($arg, 'Foo')."

However, this isn't true because not is checked the parent class.

Reproduce code:
---------------
<?php

class E {
}
class D extends E {
}

class A extends D {
}

class C extends A {
}

$ra = new ReflectionClass('A');
$rc = new ReflectionClass('C');
$rd = new ReflectionClass('D');
$re = new ReflectionClass('E');

$ca = $ra->newInstance();
$cc = $rc->newInstance();
$cd = $rd->newInstance();
$ce = $re->newInstance();

print("Is? A ". ($ra->isInstance($ca) ? 'true' : 'false') .",
instanceof: ". (($ca instanceof A) ? 'true' : 'false') ."\n");
print("Is? C ". ($ra->isInstance($cc) ? 'true' : 'false') .",
instanceof: ". (($ca instanceof C) ? 'true' : 'false') ."\n");
print("Is? D ". ($ra->isInstance($cd) ? 'true' : 'false') .",
instanceof: ". (($ca instanceof D) ? 'true' : 'false') ."\n");
print("Is? E ". ($ra->isInstance($ce) ? 'true' : 'false') .",
instanceof: ". (($ca instanceof E) ? 'true' : 'false') ."\n");

?>

Expected result:
----------------
Is? A true, instanceof: true
Is? C false, instanceof: false
Is? D true, instanceof: true
Is? E true, instanceof: true


Actual result:
--------------
Is? A true, instanceof: true
Is? C false, instanceof: false
Is? D false, instanceof: true
Is? E false, instanceof: true



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=43926&edit=1

Reply via email to