mirror of
https://github.com/php/php-src.git
synced 2024-11-28 04:14:26 +08:00
Fixed Bug#43926 (isInstance() isn't equivalent to instanceof operator)
This commit is contained in:
parent
240fa244c3
commit
8452585fc8
1
NEWS
1
NEWS
@ -240,6 +240,7 @@ PHP NEWS
|
||||
- Fixed PECL bug #11216 (crash in ZipArchive::addEmptyDir when a directory
|
||||
already exists). (Pierre)
|
||||
|
||||
- Fixed bug #43926 (isInstance() isn't equivalent to instanceof operator). (Marcus)
|
||||
- Fixed bug #42368 (Incorrect error message displayed by pg_escape_string).
|
||||
(Ilia)
|
||||
- Fixed bug #42365 (glob() crashes and/or accepts way too many flags).
|
||||
|
@ -3402,7 +3402,7 @@ ZEND_METHOD(reflection_class, isInstance)
|
||||
return;
|
||||
}
|
||||
GET_REFLECTION_OBJECT_PTR(ce);
|
||||
RETURN_BOOL(ce == Z_OBJCE_P(object));
|
||||
RETURN_BOOL(HAS_CLASS_ENTRY(*object) && instanceof_function(Z_OBJCE_P(object), ce));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
37
ext/reflection/tests/bug43926.phpt
Normal file
37
ext/reflection/tests/bug43926.phpt
Normal file
@ -0,0 +1,37 @@
|
||||
--TEST--
|
||||
Bug#43926 - isInstance() isn't equivalent to instanceof operator
|
||||
--FILE--
|
||||
<?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");
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
Is? A true, instanceof: true
|
||||
Is? C false, instanceof: false
|
||||
Is? D true, instanceof: true
|
||||
Is? E true, instanceof: true
|
Loading…
Reference in New Issue
Block a user