FAQ
Edit report at http://pear.php.net/bugs/bug.php?id=18117&edit=1

ID: 18117
Updated by: gsherwood@squiz.net
Reported By: develop at dieploegers dot de
Summary: PEAR coding standard: Method constructor not sniffed
as a function
Status: Open
Type: Bug
Package: PHP_CodeSniffer
Operating System: openSuSE 11
Package Version: 1.3.0RC1
PHP Version: 5.3.3
-Assigned To:
+Assigned To: squiz
Roadmap Versions:
New Comment:

-Assigned To:
+Assigned To: squiz
I have no idea why the sniff was coded like that in the first place, but
it was obviously deliberate because there are even unit tests to ensure
creating new objects is ignored.

I'll dig through the history a bit and see if there is any good reason
for it. If not, I agree it should be removed and just follow the same
rules. The PEAR coding standard doesn't say anything specific about
objects as far as I can see.


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

[2010-12-15 14:04:27] dploeger

Description:
------------
In the PEAR coding standard,
PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php on line #80, the
parsers exits the function code sniffer, because he's creating a new
object.

But isn't that wrong? Isn't a new object with the embedded call to the
constructor also a function call.

That way, this is valid:

$myNewObj = new NewObj("blablabla long text"
. "further long text blablabla"
);

A function call, however, prohibits the use of content after the first
open bracket...

Dennis

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

Search Discussions

  • Gsherwood at Dec 15, 2010 at 10:32 pm
    Edit report at http://pear.php.net/bugs/bug.php?id=18117&edit=1

    ID: 18117
    Updated by: gsherwood@squiz.net
    Reported By: develop at dieploegers dot de
    Summary: PEAR coding standard: Method constructor not sniffed
    as a function
    Status: Assigned
    Type: Bug
    Package: PHP_CodeSniffer
    Operating System: openSuSE 11
    Package Version: 1.3.0RC1
    PHP Version: 5.3.3
    Assigned To: squiz
    Roadmap Versions:
    New Comment:

    Well that didn't take too long to find :)

    It actually a bug fix for bug #9844

    The PEAR error reporting guidelines show that exceptions should be
    thrown differently to normal function calls. The same code they provide
    doesn't put any arguments on the first line.

    All this pre-dates the code changes to support single and multi-line
    function calls differently in the PEAR standard. With the multi-line
    function call code now available, this check for the NEW token can be
    removed.


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

    [2010-12-15 23:26:09] squiz

    -Assigned To:
    +Assigned To: squiz
    I have no idea why the sniff was coded like that in the first place, but
    it was obviously deliberate because there are even unit tests to ensure
    creating new objects is ignored.

    I'll dig through the history a bit and see if there is any good reason
    for it. If not, I agree it should be removed and just follow the same
    rules. The PEAR coding standard doesn't say anything specific about
    objects as far as I can see.

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

    [2010-12-15 14:04:27] dploeger

    Description:
    ------------
    In the PEAR coding standard,
    PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php on line #80, the
    parsers exits the function code sniffer, because he's creating a new
    object.

    But isn't that wrong? Isn't a new object with the embedded call to the
    constructor also a function call.

    That way, this is valid:

    $myNewObj = new NewObj("blablabla long text"
    . "further long text blablabla"
    );

    A function call, however, prohibits the use of content after the first
    open bracket...

    Dennis

    ------------------------------------------------------------------------
  • Gsherwood at Dec 15, 2010 at 10:34 pm
    Edit report at http://pear.php.net/bugs/bug.php?id=18117&edit=1

    ID: 18117
    Updated by: gsherwood@squiz.net
    Reported By: develop at dieploegers dot de
    Summary: PEAR coding standard: Method constructor not sniffed
    as a function
    -Status: Assigned
    +Status: Closed
    Type: Bug
    Package: PHP_CodeSniffer
    Operating System: openSuSE 11
    Package Version: 1.3.0RC1
    PHP Version: 5.3.3
    Assigned To: squiz
    Roadmap Versions:
    New Comment:

    -Status: Assigned
    +Status: Closed
    This bug has been fixed in SVN.

    If this was a documentation problem, the fix will appear on pear.php.net
    by the end of next Sunday (CET).

    If this was a problem with the pear.php.net website, the change should
    be live shortly.

    Otherwise, the fix will appear in the package's next release.

    Thank you for the report and for helping us make PEAR better.




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

    [2010-12-15 23:33:57] squiz

    Well that didn't take too long to find :)

    It actually a bug fix for bug #9844

    The PEAR error reporting guidelines show that exceptions should be
    thrown differently to normal function calls. The same code they provide
    doesn't put any arguments on the first line.

    All this pre-dates the code changes to support single and multi-line
    function calls differently in the PEAR standard. With the multi-line
    function call code now available, this check for the NEW token can be
    removed.

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

    [2010-12-15 23:26:09] squiz

    -Assigned To:
    +Assigned To: squiz
    I have no idea why the sniff was coded like that in the first place, but
    it was obviously deliberate because there are even unit tests to ensure
    creating new objects is ignored.

    I'll dig through the history a bit and see if there is any good reason
    for it. If not, I agree it should be removed and just follow the same
    rules. The PEAR coding standard doesn't say anything specific about
    objects as far as I can see.

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

    [2010-12-15 14:04:27] dploeger

    Description:
    ------------
    In the PEAR coding standard,
    PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php on line #80, the
    parsers exits the function code sniffer, because he's creating a new
    object.

    But isn't that wrong? Isn't a new object with the embedded call to the
    constructor also a function call.

    That way, this is valid:

    $myNewObj = new NewObj("blablabla long text"
    . "further long text blablabla"
    );

    A function call, however, prohibits the use of content after the first
    open bracket...

    Dennis

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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedDec 15, '10 at 10:24p
activeDec 15, '10 at 10:34p
posts3
users1
websitepear.php.net

1 user in discussion

Gsherwood: 3 posts

People

Translate

site design / logo © 2022 Grokbase