|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-01-15 19:42 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Dec 04 01:00:01 2025 UTC |
Description: ------------ The ReflectionClass::implementsInterface() correctly returns boolean true for a given interface the subject class implements, but instead of returning boolean false for one it does not, a ReflectionException is thrown instead. Reproduce code: --------------- <?php interface Polite { public static function sayHello(); } class Greeting implements Polite { public static function sayHello() { echo "Hello<br>\n"; } } Greeting::sayHello(); $refl = new ReflectionClass('Greeting'); if ($refl->implementsInterface('Polite')) { echo "Greeting implements Polite<br>\n"; } else { echo "Greeting does not implements Polite<br>\n"; } if ($refl->implementsInterface('Rude')) { echo "Greeting implements Rude<br>\n"; } else { echo "Greeting does not implement Rude<br>\n"; } ?> Expected result: ---------------- Hello Greeting implements Polite Greeting does not implement Rude Actual result: -------------- Hello Greeting implements Polite Fatal error: Uncaught exception 'ReflectionException' with message 'Interface Rude does not exist' in /home/mim/sites/intranet.home/tech/PHP/static-classes/static-object-usage.php:26 Stack trace: #0 /home/mim/sites/intranet.home/tech/PHP/static-classes/static-object-usage.php(26): ReflectionClass->implementsInterface('Rude') #1 {main} thrown in /home/mim/sites/intranet.home/tech/PHP/static-classes/static-object-usage.php on line 26