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

  ID: 20122
  Updated by: gsherwood@squiz.net
  Reported By: php dot net at web dot wnsr dot net
  Summary: PSR2 standard not catching
                     FunctionCallSignature.ContentAfterOpenBracket
-Status: Open
+Status: Closed
  Type: Bug
  Package: PHP_CodeSniffer
  Operating System: Mac OS X 10.7
  Package Version: 1.4.7
  PHP Version: Irrelevant
-Assigned To:
+Assigned To: squiz
  Roadmap Versions:
  New Comment:

-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: squiz
Arrays are now considered a single argument and do not force splitting.
So your
example is no longer considered a multi-line function call, despite it
spanning
multiple lines.

This was voted into the PSR2 errata by the PHP FIG:
https://github.com/php-fig/fig-
standards/blob/master/accepted/PSR-2-coding-style-guide-meta.md

If you don't agree, it's best to post on the mailing list, but I doubt
you will get
anywhere. I argued against this for a while because I thought the
standard was
pretty clear, but it turns out it was just written incorrectly and
didn't reflect the code
they actually wanted.


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

[2013-11-05 20:00:58] wenslayer

Description:
------------
Since upgrading to 1.4.7 from 1.4.6, phpcs is not catching the
condition where "Opening parenthesis of a
multi-line function call must be the last content on the line".
This is still part of the PSR2 standard
(https://github.com/php-fig/fig-
standards/blob/master/accepted/PSR-2-coding-style-
guide.md#6-
closures):
""""
Argument lists and variable lists MAY be split across multiple
lines, where each subsequent line is indented
once. When doing so, the first item in the list MUST be on the
next line, and there MUST be only one
argument or variable per line.
""""

I see that the PSR2 CodeSniffer standard was updated to drop
PEAR.Functions.FunctionCallSignature and
replace it with PSR2.Methods.FunctionCallSignature, and I can
see in the code that the latter is an
extension of the former:

class PSR2_Sniffs_Methods_FunctionCallSignatureSniff extends
PEAR_Sniffs_Functions_FunctionCallSignatureSniff

However, it does not catch that condition; see test script and
results below for more information.

Note this reproduces on PHP 5.3+ (tested on 5.3.27, 5.4.21 &
5.5.5). If I downgrade to phpcs 1.4.6, I get
the expected behaviour.

Test script:
---------------
$ cat foo.php
<?php
$data = json_encode(array(
     "this" => "that",
     "foo" => "bar"));
print_r($data);

# run it through the PSR2 standard and then even the specific sniff
$ phpcs -s --standard=PSR2 foo.php
$ phpcs -s --sniffs=PSR2.Methods.FunctionCallSignature foo.php


Expected result:
----------------
I would expect this result in either case:

FILE: foo.php
------------------------------------------------------------------------
--------
FOUND 2 ERROR(S) AFFECTING 2 LINE(S)
------------------------------------------------------------------------
--------
  2 | ERROR | Opening parenthesis of a multi-line function call
must be the last
content on the line
(PEAR.Functions.FunctionCallSignature.ContentAfterOpenBrack
et)
  4 | ERROR | Closing parenthesis of a multi-line function call
must be on a
line by itself
(PEAR.Functions.FunctionCallSignature.CloseBracketLine)
------------------------------------------------------------------------
--------

Time: 15 ms, Memory: 1.50Mb


Note that this can be obtained when running it against the sniff
that's supposed to be extended ('phpcs -s --
sniffs=PEAR.Functions.FunctionCallSignature foo.php').


Actual result:
--------------
$ phpcs -s --standard=PSR2 foo.php
Time: 11 ms, Memory: 1.50Mb

(no errors reported)

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

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 1 | next ›
Discussion Overview
grouppear-bugs @
categoriesphp
postedNov 6, '13 at 12:53a
activeNov 6, '13 at 12:53a
posts1
users1
websitepear.php.net

1 user in discussion

Gsherwood: 1 post

People

Translate

site design / logo © 2022 Grokbase