Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHPCBF fails to fix code with heredoc/nowdoc as first argument to a function #1224

Closed
sc0rp10 opened this issue Nov 29, 2016 · 2 comments
Closed

Comments

@sc0rp10
Copy link

sc0rp10 commented Nov 29, 2016

Hi!
If the file contains code like:

<?php

var_dump(
    <<<TEXT
foo
TEXT
    ,
    'bar'
);

I got error:

$ ./vendor/bin/phpcbf --standard=PSR2 t.php -vvv --report=diff
Changing into directory /tmp/t
Processing t.php [PHP => 19 tokens in 9 lines]... DONE in 1ms (1 fixable violations)
        => Fixing file: 1/1 violations remaining [made 50 passes]... ERROR in 40ms
No fixable errors were found
Time: 72ms; Memory: 4Mb
$ ./vendor/bin/phpcbf --version
PHP_CodeSniffer version 2.7.0 (stable) by Squiz (http://www.squiz.net)
@gsherwood
Copy link
Member

gsherwood commented Nov 29, 2016

There is a conflict during fixing that is causing this issue:

	*** START FILE FIXING ***
---START FILE CONTENT---
 1|<?php
 2|
 3|var_dump(
 4|    <<<TEXT
 5|foo
 6|TEXT
 7|    ,
 8|    'bar'
 9|);
10|
--- END FILE CONTENT ---
	E: [Line 7] Space found before comma in function call (Generic.Functions.FunctionCallArgumentSpacing.SpaceBeforeComma)
	Generic_Sniffs_Functions_FunctionCallArgumentSpacingSniff (line 118) replaced token 10 (T_WHITESPACE) "····," => ","
	* fixed 1 violations, starting loop 2 *
---START FILE CONTENT---
 1|<?php
 2|
 3|var_dump(
 4|    <<<TEXT
 5|foo
 6|TEXT
 7|,
 8|    'bar'
 9|);
10|
--- END FILE CONTENT ---
	E: [Line 7] Multi-line function call not indented correctly; expected 4 spaces but found 0 (PSR2.Methods.FunctionCallSignature.Indent)
	PEAR_Sniffs_Functions_FunctionCallSignatureSniff (line 458) replaced token 10 (T_COMMA) "," => "····,"
	* fixed 1 violations, starting loop 3 *
---START FILE CONTENT---
 1|<?php
 2|
 3|var_dump(
 4|    <<<TEXT
 5|foo
 6|TEXT
 7|    ,
 8|    'bar'
 9|);
10|

@gsherwood gsherwood changed the title phpcbf fails to fix code with heredoc/nowdoc PHPCBF fails to fix code with heredoc/nowdoc as first argument to a function Nov 29, 2016
gsherwood added a commit that referenced this issue Nov 29, 2016
@gsherwood
Copy link
Member

This is now fixed. The sniff should have been ignoring the space before the comma, but the logic for location the end of the here/nowdoc was incorrect. Thanks for the report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants