ID:               43987
 Updated by:       [EMAIL PROTECTED]
 Reported By:      ms419 at freezone dot co dot uk
-Status:           Open
+Status:           Bogus
 Bug Type:         Class/Object related
 Operating System: Debian
 PHP Version:      5.2.5
 New Comment:

.


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

[2008-01-31 10:25:38] [EMAIL PROTECTED]

This is not a bug.

Actually, PHP only accepts:
... instanceof $var
... instanceof $obj->property->...
... instanceof className
... instanceof Foo::bar::...

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

[2008-01-31 01:42:32] ms419 at freezone dot co dot uk

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 this bug report at http://bugs.php.net/?id=43987&edit=1

Reply via email to