php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #45331 Imagick::clone with trailing space results in ParserError
Submitted: 2008-06-22 23:03 UTC Modified: 2008-11-17 19:37 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: j dot jeising at gmail dot com Assigned: scottmac (profile)
Status: Not a bug Package: Class/Object related
PHP Version: 5.2.6 OS: Mac OS X 10.5.3
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
39 - 25 = ?
Subscribe to this entry?

 
 [2008-06-22 23:03 UTC] j dot jeising at gmail dot com
Description:
------------
With a space between -> and Imagick::clone PHP throws a parser error. Without the space everything is perfect.

Reproduce code:
---------------
$imagick = new Imagick ( 'path/to/a/image.jpg' );
$clone = $imagick -> clone ( ); // Spaces important!
// Code which runs:
//$clone = $imagick ->clone ( );

Expected result:
----------------
Clone of $imagick in $clone.

Actual result:
--------------
Parse error:  syntax error, unexpected T_CLONE, expecting T_STRING or T_VARIABLE or '{' or '$' in .../file.php on line 2


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-06-22 23:20 UTC] pajoye@php.net
report bug for imagick in http://pecl.php.net/imagick
 [2008-06-22 23:24 UTC] pajoye@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows (zip):
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip

For Windows (installer):

  http://snaps.php.net/win32/php5.2-win32-installer-latest.msi

Oops, misread but I can't reproduce the problem with:

class a { function foo(){echo "foo\n";}} $b = new a; $b -> foo();
 [2008-06-23 00:14 UTC] j dot jeising at gmail dot com
Pajoye, I think that's not a problem of imagick, more a parser problem. You can't reproduce the problem because foo() is not clone(). "clone" is a reserved keyword (http://docs.php.net/clone), imagick can use this function because it's in the class namespace (http://docs.php.net/manual/en/function.imagick-clone.php). PHP supports this if the parser detects "->" before the keyword. But the parser does not recognize the space in this case.
 [2008-06-23 00:28 UTC] pajoye@php.net
Yes, I misread the initial report. My 2nd comment asked you to test with a snapshot.
 [2008-06-23 00:30 UTC] j dot jeising at gmail dot com
Tested with latest snapshot on windows

php test.php
Parse error: syntax error, unexpected T_CLONE, expecting T_STRING or T_VARIABLE
or '{' or '$' in test.php on line 4

Same probleme here.
 [2008-06-23 00:33 UTC] pajoye@php.net
Weird, it works here on windows and linux.

Can you zip your src and post a link to it here please? Maybe there is a hidden character (not a space)?
 [2008-06-23 00:38 UTC] j dot jeising at gmail dot com
Download file here: http://jannes.webkassel.de/test.php.zip
 [2008-06-24 00:03 UTC] j dot jeising at gmail dot com
Testcase:

--TEST--
Bug #45331 (Imagick::clone with trailing space results in ParserError)
--FILE--
<?php
$imagick = new Imagick ( 'image.jpg' );
$clone = $imagick -> clone ( );
var_dump ( $clone );
?>
--EXPECT--
object(Imagick)#2 (0) { }
 [2008-06-30 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2008-06-30 23:27 UTC] j dot jeising at gmail dot com
Feedback from developers missing here.
 [2008-06-30 23:32 UTC] pajoye@php.net
Scott, can you take a look? You may be the best person to check the parser :)
 [2008-07-01 10:15 UTC] scottmac@php.net
This is fixed in PHP 5.3 since the move to re2c, I will see whats possible for the 5.2 branch.
 [2008-07-02 14:46 UTC] j dot jeising at gmail dot com
I detect, that the bug affects all keywords with Object Operator before, example:

$this -> class = 'foobar';
 [2008-11-17 19:37 UTC] scottmac@php.net
This isn't a bug in 5.2, its just a limitation of flex.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Apr 15 15:01:29 2024 UTC