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

ControlStructureSpacingSniff fails on multiline string #2642

Closed
alpha0010 opened this issue Oct 8, 2019 · 1 comment
Closed

ControlStructureSpacingSniff fails on multiline string #2642

alpha0010 opened this issue Oct 8, 2019 · 1 comment

Comments

@alpha0010
Copy link

Fails (with infinite loop?) when handling a multiline string.

/ccel-shared# cli/vendor/bin/phpcs --version                 
PHP_CodeSniffer version 3.5.0 (stable) by Squiz (http://www.squiz.net)

/ccel-shared# cli/vendor/bin/phpcs --standard=PSR12 test.php 

FILE: /ccel-shared/test.php
----------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 2 LINES
----------------------------------------------------------------------
 3 | ERROR | [x] The first expression of a multi-line control
   |       |     structure must be on the line after the opening
   |       |     parenthesis
 6 | ERROR | [x] Each line in a multi-line control structure must be
   |       |     indented at least once; expected at least 4 spaces,
   |       |     but found 0
 6 | ERROR | [x] The closing parenthesis of a multi-line control
   |       |     structure must be on the line after the last
   |       |     expression
----------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

Time: 72ms; Memory: 6MB

/ccel-shared# cli/vendor/bin/phpcbf -v --standard=PSR12 test.php 
Registering sniffs in the PSR12 standard... DONE (59 sniffs registered)
Creating file list... DONE (1 files in queue)
Changing into directory /ccel-shared
Processing test.php [PHP => 31 tokens in 8 lines]... DONE in 3ms (3 fixable violations)
        => Fixing file: 1/3 violations remaining [made 50 passes]... ERROR in 228ms

PHPCBF RESULT SUMMARY
----------------------------------------------------------------------
FILE                                                  FIXED  REMAINING
----------------------------------------------------------------------
/ccel-shared/test.php                                 FAILED TO FIX
----------------------------------------------------------------------
A TOTAL OF 2 ERRORS WERE FIXED IN 1 FILE
----------------------------------------------------------------------
PHPCBF FAILED TO FIX 1 FILE
----------------------------------------------------------------------

Time: 303ms; Memory: 6MB
<?php

if (preg_match("/
                  foo # The first part.
                  bar # the second part.
                /x", "foobar") === 1) {
    echo "success\n";
}
@jrfnl
Copy link
Contributor

jrfnl commented Oct 8, 2019

Duplicate of #2623 ? (already fixed)

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

No branches or pull requests

2 participants