From:             ms419 at freezone dot co dot uk
Operating system: Debian
PHP version:      5.2.5
PHP Bug Type:     Class/Object related
Bug description:  parse error when second instanceof operand is function call

Description:
------------
PHP raises a parse error when the second operand of an instanceof operator
is a function call. In my case, the function call,
$relatedTable->getPhpName(), returns the class name as a string, which I
want to determine whether $obj is an instance of.

Reproduce code:
---------------
              if (!$obj instanceof $relatedTable->getPhpName())
              {
                if
(!isset($this->object_references[$relatedTable->getPhpName().'_'.$value]))
                {
                  throw new sfException(sprintf('The object "%s" from
class "%s" is not defined in your data file.', $value,
$relatedTable->getPhpName()));
                }
                $value =
$this->object_references[$relatedTable->getPhpName().'_'.$value]->getPrimaryKey();
              }


Expected result:
----------------
The instanceof operator should determine whether $obj is an instance of
the class name returned by $relatedTable->getPhpName()

Actual result:
--------------
Parse error: syntax error, unexpected '(' in
/home/jablko/public_html/qubit/lib/vendor/symfony/lib/plugins/sfPropelPlugin/lib/propel/sfPropelData.class.php
on line 133

Line 133 is the first line of the reproduce code: if (!$obj instanceof
$relatedTable->getPhpName())

This also raises a parse error: if (!$obj instanceof $relatedPhpName =
$relatedTable->getPhpName())

Parse error: syntax error, unexpected '=' in
/home/jablko/public_html/qubit/lib/vendor/symfony/lib/plugins/sfPropelPlugin/lib/propel/sfPropelData.class.php
on line 133

However the following works:

              $relatedPhpName = $relatedTable->getPhpName();
              if (!$obj instanceof $relatedPhpName)
              {
                if
(!isset($this->object_references[$relatedTable->getPhpName().'_'.$value]))
                {
                  throw new sfException(sprintf('The object "%s" from
class "%s" is not defined in your data file.', $value,
$relatedTable->getPhpName()));
                }
                $value =
$this->object_references[$relatedTable->getPhpName().'_'.$value]->getPrimaryKey();
              }


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

Reply via email to