Issues

ZF-6996: Parameter descriptions are incorrectly parsed by Zend_Server_Reflection_Function_Abstract _reflect() regular expression

Issue Type: Bug Created: 2009-06-12T08:27:46.000+0000 Last Updated: 2010-01-25T14:34:06.000+0000 Status: Resolved Fix version(s): - 1.10.0 (27/Jan/10)

Reporter: Georg-Hendrik Haan (haan) Assignee: Matthew Weier O'Phinney (matthew) Tags: - Zend_Server_Reflection

Related issues: - ZF-7344

Attachments: - Zend_Server_Reflection_Function_Abstract.php.patch

Description

Zend_Server_Reflection_Function_Abstract, line 296:

<pre class="highlight">

This regular expression is to extract the parameter name and description from a parameter definition comment:

The part that scans for a variable name, ``` I.e. "dollar sign followed by one or more characters that are not - not whitespace" must read "dollar sign followed by one or more characters that are not whitespace"

Comments

Posted by Stephen Leavitt (subzero2000) on 2009-07-21T20:53:33.000+0000

Actually, the regex means "dollar sign followed by the beginning of a line followed by one or more characters that are not whitespace".

A circumflex outside of a character class (square brackets) means the beginning of a line, whereas a circumflex as the first character in a character class means that the character does not match any of the characters in the character class.

The part that scans for a variable name,

<pre class="literal">
(\$^\S+)

should instead read

<pre class="literal">
(\$\S+)

i.e. just remove the extraneous circumflex

Posted by Stephen Leavitt (subzero2000) on 2009-07-21T20:57:26.000+0000

Actually, I just discovered that a circumflex used outside of a character class is an assertion which is true only if the current matching point is at the start of the subject string, which does not necessarily imply the beginning of a line.

[http://php.net/manual/en/…]

Posted by Stephen Leavitt (subzero2000) on 2009-07-21T20:59:25.000+0000

Uploading patch previously uploaded to ZF-7344, which is a duplicate of this issue.

Posted by Penny Leach (mjollnir) on 2010-01-24T21:19:56.000+0000

I was affected by this too, and came to exactly the same patch before finding this bug. It would be great if this could be fixed! :)

Posted by Matthew Weier O'Phinney (matthew) on 2010-01-25T12:12:23.000+0000

Fixed on trunk and 1.10 release branch.

Posted by Marc Bennewitz (private) (mabe) on 2010-01-25T13:45:23.000+0000

This patch crashes Zend_Json tests:

<pre class="highlight">
# svn up -r 20618 library/Zend/Server/Reflection
U    library/Zend/Server/Reflection/Function/Abstract.php
Updated to revision 20618.

# php tests/Zend/Json/AllTests.php
PHPUnit 3.4.5 by Sebastian Bergmann.

........EEEEE..........E....................................  60 / 141
............................................................ 120 / 141
.....................

Time: 0 seconds, Memory: 13.25Mb

There were 6 errors:

1) Zend_Json_ServerTest::testShouldBeAbleToBindClassToServer
Undefined offset: 1

/home/mabe/workspace/zf-trunk/library/Zend/Server/Reflection/Function/Abstract.php:240
/home/mabe/workspace/zf-trunk/library/Zend/Server/Reflection/Function/Abstract.php:354
/home/mabe/workspace/zf-trunk/library/Zend/Server/Reflection/Method.php:83
/home/mabe/workspace/zf-trunk/library/Zend/Server/Reflection/Class.php:90
/home/mabe/workspace/zf-trunk/library/Zend/Server/Reflection.php:76
/home/mabe/workspace/zf-trunk/library/Zend/Json/Server.php:151
/home/mabe/workspace/zf-trunk/tests/Zend/Json/ServerTest.php:98
/home/mabe/workspace/zf-trunk/tests/Zend/Json/AllTests.php:45
/home/mabe/workspace/zf-trunk/tests/Zend/Json/AllTests.php:61

2) Zend_Json_ServerTest::testBindingClassToServerShouldRegisterAllPublicMethods
Undefined offset: 1

/home/mabe/workspace/zf-trunk/library/Zend/Server/Reflection/Function/Abstract.php:240
/home/mabe/workspace/zf-trunk/library/Zend/Server/Reflection/Function/Abstract.php:354
/home/mabe/workspace/zf-trunk/library/Zend/Server/Reflection/Method.php:83
/home/mabe/workspace/zf-trunk/library/Zend/Server/Reflection/Class.php:90
/home/mabe/workspace/zf-trunk/library/Zend/Server/Reflection.php:76
/home/mabe/workspace/zf-trunk/library/Zend/Json/Server.php:151
/home/mabe/workspace/zf-trunk/tests/Zend/Json/ServerTest.php:105
/home/mabe/workspace/zf-trunk/tests/Zend/Json/AllTests.php:45
/home/mabe/workspace/zf-trunk/tests/Zend/Json/AllTests.php:61

3) Zend_Json_ServerTest::testShouldBeAbleToBindObjectToServer
Undefined offset: 1

/home/mabe/workspace/zf-trunk/library/Zend/Server/Reflection/Function/Abstract.php:240
/home/mabe/workspace/zf-trunk/library/Zend/Server/Reflection/Function/Abstract.php:354
/home/mabe/workspace/zf-trunk/library/Zend/Server/Reflection/Method.php:83
/home/mabe/workspace/zf-trunk/library/Zend/Server/Reflection/Class.php:90
/home/mabe/workspace/zf-trunk/library/Zend/Server/Reflection.php:76
/home/mabe/workspace/zf-trunk/library/Zend/Json/Server.php:151
/home/mabe/workspace/zf-trunk/tests/Zend/Json/ServerTest.php:119
/home/mabe/workspace/zf-trunk/tests/Zend/Json/AllTests.php:45
/home/mabe/workspace/zf-trunk/tests/Zend/Json/AllTests.php:61

4) Zend_Json_ServerTest::testBindingObjectToServerShouldRegisterAllPublicMethods
Undefined offset: 1

/home/mabe/workspace/zf-trunk/library/Zend/Server/Reflection/Function/Abstract.php:240
/home/mabe/workspace/zf-trunk/library/Zend/Server/Reflection/Function/Abstract.php:354
/home/mabe/workspace/zf-trunk/library/Zend/Server/Reflection/Method.php:83
/home/mabe/workspace/zf-trunk/library/Zend/Server/Reflection/Class.php:90
/home/mabe/workspace/zf-trunk/library/Zend/Server/Reflection.php:76
/home/mabe/workspace/zf-trunk/library/Zend/Json/Server.php:151
/home/mabe/workspace/zf-trunk/tests/Zend/Json/ServerTest.php:127
/home/mabe/workspace/zf-trunk/tests/Zend/Json/AllTests.php:45
/home/mabe/workspace/zf-trunk/tests/Zend/Json/AllTests.php:61

5) Zend_Json_ServerTest::testShouldBeAbleToBindMultipleClassesAndObjectsToServer
Undefined offset: 1

/home/mabe/workspace/zf-trunk/library/Zend/Server/Reflection/Function/Abstract.php:240
/home/mabe/workspace/zf-trunk/library/Zend/Server/Reflection/Function/Abstract.php:354
/home/mabe/workspace/zf-trunk/library/Zend/Server/Reflection/Method.php:83
/home/mabe/workspace/zf-trunk/library/Zend/Server/Reflection/Class.php:90
/home/mabe/workspace/zf-trunk/library/Zend/Server/Reflection.php:76
/home/mabe/workspace/zf-trunk/library/Zend/Json/Server.php:151
/home/mabe/workspace/zf-trunk/tests/Zend/Json/ServerTest.php:140
/home/mabe/workspace/zf-trunk/tests/Zend/Json/AllTests.php:45
/home/mabe/workspace/zf-trunk/tests/Zend/Json/AllTests.php:61

6) Zend_Json_ServerTest::testSmdObjectRetrievedFromServerShouldReflectServerState
Undefined offset: 1

/home/mabe/workspace/zf-trunk/library/Zend/Server/Reflection/Function/Abstract.php:240
/home/mabe/workspace/zf-trunk/library/Zend/Server/Reflection/Function/Abstract.php:354
/home/mabe/workspace/zf-trunk/library/Zend/Server/Reflection/Method.php:83
/home/mabe/workspace/zf-trunk/library/Zend/Server/Reflection/Class.php:90
/home/mabe/workspace/zf-trunk/library/Zend/Server/Reflection.php:76
/home/mabe/workspace/zf-trunk/library/Zend/Json/Server.php:151
/home/mabe/workspace/zf-trunk/tests/Zend/Json/ServerTest.php:240
/home/mabe/workspace/zf-trunk/tests/Zend/Json/AllTests.php:45
/home/mabe/workspace/zf-trunk/tests/Zend/Json/AllTests.php:61

FAILURES!
Tests: 141, Assertions: 561, Errors: 6.



<pre class="highlight">
# svn up -r 20617 library/Zend/Server/Reflection
U    library/Zend/Server/Reflection/Function/Abstract.php
Updated to revision 20617.

# php tests/Zend/Json/AllTests.php
PHPUnit 3.4.5 by Sebastian Bergmann.

............................................................  60 / 141
............................................................ 120 / 141
.....................

Time: 0 seconds, Memory: 14.50Mb

OK (141 tests, 619 assertions)

Posted by Matthew Weier O'Phinney (matthew) on 2010-01-25T14:34:06.000+0000

Fixed in trunk and 1.10 release branch. Fixing this issue exposed another issue, basically, and this is now resolved.

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts