php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #46593 $object instanceof __CLASS__ is not allowed
Submitted: 2008-11-17 13:17 UTC Modified: 2008-11-17 13:22 UTC
From: jtaal at eljakim dot nl Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 5.2.6 OS: Irrelevant
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: jtaal at eljakim dot nl
New email:
PHP Version: OS:

 

 [2008-11-17 13:17 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-11-17 13:22 UTC] jtaal at eljakim dot nl
I've found the solution:

$otherObject instanceof self

(maybe someone can find this issue using a searchengine)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 22:01:30 2024 UTC