#40136 [Opn->Bgs]: ReflectionClass::implementsInterface() thowing exception
| From: | tony2001@php.net | Date: | Mon, 15 Jan 2007 19:42:15 +0000 |
| Subject: | #40136 [Opn->Bgs]: ReflectionClass::implementsInterface() thowing exception | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-107626@lists.php.net to get a copy of this message | ||
ID: 40136
Updated by: tony2001@php.net
Reported By: mark dot 2391 at blueyonder dot co dot uk
-Status: Open
+Status: Bogus
Bug Type: Class/Object related
Operating System: Debian GNU/Linux
PHP Version: 5.2.0
New Comment:
>but instead of returning boolean false for one it does
>not, a ReflectionException is thrown instead.
ReflectionClass::implementsInterface() throws exception only if the
interface does not exist and this is expected.
Previous Comments:
------------------------------------------------------------------------
[2007-01-15 19:27:55] mark dot 2391 at blueyonder dot co dot uk
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
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=40136&edit=1