#46593 [Opn->Csd]: $object instanceof __CLASS__ is not allowed

From: Date: Mon, 17 Nov 2008 13:22:47 +0000
Subject: #46593 [Opn->Csd]: $object instanceof __CLASS__ is not allowed
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-131031@lists.php.net to get a copy of this message
 ID:               46593
 User updated by:  jtaal at eljakim dot nl
 Reported By:      jtaal at eljakim dot nl
-Status:           Open
+Status:           Closed
 Bug Type:         Feature/Change Request
 Operating System: Irrelevant
 PHP Version:      5.2.6
 New Comment:

I've found the solution:

$otherObject instanceof self

(maybe someone can find this issue using a searchengine)


Previous Comments:
------------------------------------------------------------------------

[2008-11-17 13:17:22] jtaal at eljakim dot nl

Description:
------------
The PHP parser currently cannot handle "__CLASS__" directly after
"instanceof". I think this should be possible.

Reproduce code:
---------------
class myclass {
    function mymethod($otherObject) {
        if ($otherObject instanceof __CLASS__) {
            $otherObject->mymethod(null);
        }
        return 'works!';
    }
}

$a = new myclass();
print $a->mymethod($a);

Expected result:
----------------
works!

Actual result:
--------------
Parse error: syntax error, unexpected T_CLASS_C, expecting T_STRING or
T_VARIABLE or '$' in ... on line 4


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=46593&edit=1



Thread (2 messages)

« previous php.bugs (#131031) next »