ID:               40136
 Updated by:       [EMAIL PROTECTED]
 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

Reply via email to