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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Fri May 09 12:01:28 2025 UTC