note 125252 deleted from language.operators.type by cmb

From: Date: Fri, 07 Aug 2020 11:19:06 +0000
Subject: note 125252 deleted from language.operators.type by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-214936@lists.php.net to get a copy of this message
Note Submitter: InvisibleSmiley ---- 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" }

« previous php.notes (#214936) next »