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

ID: 19537
Updated by: gsherwood@squiz.net
Reported By: hinikato at mail dot ru
Summary: The PSR-2 reports errors for strings that contain
line break
-Status: Open
+Status: Bogus
Type: Bug
Package: PHP_CodeSniffer
Operating System: Windows 7
Package Version: 1.3.5
PHP Version: 5.4.0
-Assigned To:
+Assigned To: squiz
Roadmap Versions:
New Comment:

-Status: Open
+Status: Bogus
-Assigned To:
+Assigned To: squiz
This isn't a bug. The PSR-2 standard is pretty clear: "Argument 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 per line."

Then is shows some example code: https://github.com/pmjones/fig-
standards/blob/psr-1-style-guide/proposed/PSR-2-advanced.md#45-method-and-
function-calls

Even though your string has a newline in it, it still counts a a
multi-line function call.
So I suggest you write your code like this:

$this->assertEquals('3.1415', $this->filter->filter("ab3 , c1
f\n4fa^1**5z"));

Or assign the string to a var before using it.


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

[2012-08-01 19:02:37] hinikato

The bug occurs for the latest phpcs from github.

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

[2012-08-01 19:00:24] hinikato

-Summary: The PSR-2 reports errors for strings that contains
line break
+Summary: The PSR-2 reports errors for strings that contain
line break


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

[2012-08-01 19:00:14] hinikato

-Summary: The PSR-2 reports errors for strings
+Summary: The PSR-2 reports errors for strings that contains
line break


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

[2012-08-01 18:59:36] hinikato

Description:
------------
I have a PHPUnit test that compares strings:
public function testCanFilterMixedValue()
{
$this->assertEquals('3.1415', $this->filter->filter('ab3 , c1 f
4fa^1**5z'));
}

but this lines reported as invalid.

Test script:
---------------
phpcs --standard=PSR2
----
public function testCanFilterMixedValue()
{
$this->assertEquals('3.1415', $this->filter->filter('ab3 , c1 f
4fa^1**5z'));
}

Expected result:
----------------
No errors should be reported.

Actual result:
--------------
FILE: D:\system\home\project\myak2\src\test\Myak\Filter\PriceTest.php
--------------------------------------------------------------------------------
FOUND 5 ERROR(S) AFFECTING 2 LINE(S)
--------------------------------------------------------------------------------
25 | ERROR | Opening parenthesis of a multi-line function call must be
the
last content on the line
25 | ERROR | Only one argument is allowed per line in a multi-line
function
call
25 | ERROR | Opening parenthesis of a multi-line function call must be
the
last content on the line
26 | ERROR | Closing parenthesis of a multi-line function call must be
on a
line by itself
26 | ERROR | Closing parenthesis of a multi-line function call must be
on a
line by itself
--------------------------------------------------------------------------------

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

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedAug 6, '12 at 12:57a
activeAug 6, '12 at 12:57a
posts1
users1
websitepear.php.net

1 user in discussion

Gsherwood: 1 post

People

Translate

site design / logo © 2022 Grokbase