#46593 [NEW]: $object instanceof __CLASS__ is not allowed

From: Date: Mon, 17 Nov 2008 13:17:23 +0000
Subject: #46593 [NEW]: $object instanceof __CLASS__ is not allowed
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-131030@lists.php.net to get a copy of this message
From:             jtaal at eljakim dot nl
Operating system: Irrelevant
PHP version:      5.2.6
PHP Bug Type:     Feature/Change Request
Bug description:  $object instanceof __CLASS__ is not allowed

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 bug report at http://bugs.php.net/?id=46593&edit=1
-- 
Try a CVS snapshot (PHP 5.2):        http://bugs.php.net/fix.php?id=46593&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):        http://bugs.php.net/fix.php?id=46593&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):        http://bugs.php.net/fix.php?id=46593&r=trysnapshot60
Fixed in CVS:                        http://bugs.php.net/fix.php?id=46593&r=fixedcvs
Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=46593&r=needdocs
Fixed in release:                    http://bugs.php.net/fix.php?id=46593&r=alreadyfixed
Need backtrace:                      http://bugs.php.net/fix.php?id=46593&r=needtrace
Need Reproduce Script:               http://bugs.php.net/fix.php?id=46593&r=needscript
Try newer version:                   http://bugs.php.net/fix.php?id=46593&r=oldversion
Not developer issue:                 http://bugs.php.net/fix.php?id=46593&r=support
Expected behavior:                   http://bugs.php.net/fix.php?id=46593&r=notwrong
Not enough info:                     http://bugs.php.net/fix.php?id=46593&r=notenoughinfo
Submitted twice:                     http://bugs.php.net/fix.php?id=46593&r=submittedtwice
register_globals:                    http://bugs.php.net/fix.php?id=46593&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=46593&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=46593&r=dst
IIS Stability:                       http://bugs.php.net/fix.php?id=46593&r=isapi
Install GNU Sed:                     http://bugs.php.net/fix.php?id=46593&r=gnused
Floating point limitations:          http://bugs.php.net/fix.php?id=46593&r=float
No Zend Extensions:                  http://bugs.php.net/fix.php?id=46593&r=nozend
MySQL Configuration Error:           http://bugs.php.net/fix.php?id=46593&r=mysqlcfg



Thread (2 messages)

« previous php.bugs (#131030) next »