note 125252 added to language.operators.type
| From: | InvisibleSmiley@php.net | Date: | Fri, 07 Aug 2020 09:19:41 +0000 |
| Subject: | note 125252 added to language.operators.type | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-214935@lists.php.net to get a copy of this message | ||
It seems instanceof only supports checking for directly implemented interfaces, not inherited ones:
<?php
interface FooBarInterface {
}
class Bar implements FooBarInterface {
}
class Foo extends Bar {
}
$className = Foo::class;
var_dump($className instanceof FooBarInterface);
var_dump(is_subclass_of($className, FooBarInterface::class));
var_dump(class_implements($className));
?>
Result:
bool(false)
bool(true)
array(1) {
["FooBarInterface"]=>
string(15) "FooBarInterface"
}
----
Server IP: 45.112.84.4
Probable Submitter: 103.51.166.36 (proxied: 213.155.83.52)
----
Manual Page -- http://php.net/manual/en/language.operators.type.php
Edit -- https://master.php.net/note/edit/125252
Del: integrated -- https://master.php.net/note/delete/125252/integrated
Del: useless -- https://master.php.net/note/delete/125252/useless
Del: bad code -- https://master.php.net/note/delete/125252/bad+code
Del: spam -- https://master.php.net/note/delete/125252/spam
Del: non-english -- https://master.php.net/note/delete/125252/non-english
Del: in docs -- https://master.php.net/note/delete/125252/in+docs
Del: other reasons-- https://master.php.net/note/delete/125252
Reject -- https://master.php.net/note/reject/125252
Search -- https://master.php.net/manage/user-notes.php