note 75633 added to language.oop5.reflection
| From: | LuigiBai at osu1 dot php dot net | Date: | Fri, 08 Jun 2007 22:45:21 +0000 |
| Subject: | note 75633 added to language.oop5.reflection | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-127334@lists.php.net to get a copy of this message | ||
Note: $class = new ReflectionClass('Foo'); $class->isInstance($arg) is equivalent to
$arg instanceof Foo or is_a($arg, 'Foo').
This is not correct. Consider the following code:
class A {
}
class C extends A {
}
$rc = new ReflectionClass("C");
$ra = new ReflectionClass("A");
$cc = $rc->newInstance();
$ca = $ra->newInstance();
print("Is? A ".($ra->isInstance($ca)?"true":"false").", but
instanceof: ".(($ca instanceof A)?"true":"false")."\n");
print("Is? C ".($ra->isInstance($cc)?"true":"false").", but
instanceof: ".(($cc instanceof A)?"true":"false")."\n");
----
Server IP: 69.147.83.197
Probable Submitter: 87.106.27.17 (proxied: 127.0.0.1)
----
Manual Page -- http://www.php.net/manual/en/language.oop5.reflection.php
Edit -- https://master.php.net/note/edit/75633
Del: integrated -- https://master.php.net/note/delete/75633/integrated
Del: useless -- https://master.php.net/note/delete/75633/useless
Del: bad code -- https://master.php.net/note/delete/75633/bad+code
Del: spam -- https://master.php.net/note/delete/75633/spam
Del: non-english -- https://master.php.net/note/delete/75633/non-english
Del: in docs -- https://master.php.net/note/delete/75633/in+docs
Del: other reasons-- https://master.php.net/note/delete/75633
Reject -- https://master.php.net/note/reject/75633
Search -- https://master.php.net/manage/user-notes.php