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

Generic.Arrays.ArrayIndent & Generic.WhiteSpace.ScopeIndent conflict #19

Open
autowp opened this issue Mar 14, 2020 · 3 comments
Open
Labels
Bug Something isn't working

Comments

@autowp
Copy link
Contributor

autowp commented Mar 14, 2020

Bug Report

Q A
Version(s) 2.0.0rc1

Summary

phpcbf loops until attempts limit (50) with rules Generic.Arrays.ArrayIndent & Generic.WhiteSpace.ScopeIndent then failed to fix.
On big sources failed on time limit (10min)

Current behavior

$./vendor/bin/phpcbf test.php
----------------------------------------------------------------------
FILE                                                  FIXED  REMAINING
----------------------------------------------------------------------
test.php                                              FAILED TO FIX
----------------------------------------------------------------------
A TOTAL OF 1 ERROR WERE FIXED IN 1 FILE
----------------------------------------------------------------------
PHPCBF FAILED TO FIX 1 FILE
----------------------------------------------------------------------

How to reproduce

Minimal source to reproduce:

<?php

function test()
{
    query('
        INSERT INTO table (column)
        VALUES (:value)
    ', [
        'value' => $value,
    ]);
}

Expected behavior

No error (all other rules applied)

Verbose output fragment

$./vendor/bin/phpcbf test.php -vvvv

---START FILE CONTENT---
 1|<?php
 2|
 3|function test()
 4|{
 5|    query('
 6|        INSERT INTO table (column)
 7|        VALUES (:value)
 8|    ', [
 9|    'value' => $value,
10|    ]);
11|}
12|
--- END FILE CONTENT ---
	**** Generic.Arrays.ArrayIndent:137 has possible conflict with another sniff on loop 45; caused by the following change ****
	**** replaced token 29 (T_WHITESPACE on line 10) "····]" => "]" ****
	**** ignoring all changes until next loop ****
        => Fixing file: 0/2 violations remaining [made 47 passes]...    * fixed 0 violations, starting loop 48 *
---START FILE CONTENT---
 1|<?php
 2|
 3|function test()
 4|{
 5|    query('
 6|        INSERT INTO table (column)
 7|        VALUES (:value)
 8|    ', [
 9|    'value' => $value,
10|    ]);
11|}
12|
--- END FILE CONTENT ---
	Generic.Arrays.ArrayIndent:137 replaced token 29 (T_WHITESPACE on line 10) "····]" => "]"
        => Fixing file: 1/2 violations remaining [made 48 passes]...    * fixed 1 violations, starting loop 49 *
---START FILE CONTENT---
 1|<?php
 2|
 3|function test()
 4|{
 5|    query('
 6|        INSERT INTO table (column)
 7|        VALUES (:value)
 8|    ', [
 9|    'value' => $value,
10|]);
11|}
12|
--- END FILE CONTENT ---
	**** Generic.WhiteSpace.ScopeIndent:1476 has possible conflict with another sniff on loop 47; caused by the following change ****
	**** replaced token 29 (T_CLOSE_SHORT_ARRAY on line 10) "]" => "····]" ****
	**** ignoring all changes until next loop ****
        => Fixing file: 0/2 violations remaining [made 49 passes]...    * fixed 0 violations, starting loop 50 *
---START FILE CONTENT---
 1|<?php
 2|
 3|function test()
 4|{
 5|    query('
 6|        INSERT INTO table (column)
 7|        VALUES (:value)
 8|    ', [
 9|    'value' => $value,
10|]);
11|}
12|
--- END FILE CONTENT ---
	Generic.WhiteSpace.ScopeIndent:1476 replaced token 29 (T_CLOSE_SHORT_ARRAY on line 10) "]" => "····]"
        => Fixing file: 1/2 violations remaining [made 50 passes]...    * fixed 1 violations, starting loop 51 *
	*** Reached maximum number of loops with 1 violations left unfixed ***
ERROR in 217ms

PHPCBF RESULT SUMMARY
----------------------------------------------------------------------
FILE                                                  FIXED  REMAINING
----------------------------------------------------------------------
test.php                                              FAILED TO FIX
----------------------------------------------------------------------
A TOTAL OF 1 ERROR WERE FIXED IN 1 FILE
----------------------------------------------------------------------
PHPCBF FAILED TO FIX 1 FILE
----------------------------------------------------------------------

Time: 292ms; Memory: 10MB
@Xerkus
Copy link
Member

Xerkus commented Mar 14, 2020

TBH, I wouldn't know how to fix it either

@geerteltink
Copy link
Member

Thank you for reporting this issue. However this is not something we can fix. I've opened a phpcs issue with the info you provided: squizlabs/PHP_CodeSniffer#2905

@geerteltink geerteltink reopened this Mar 16, 2020
@geerteltink geerteltink added the Bug Something isn't working label Mar 16, 2020
@geerteltink
Copy link
Member

I've been finding a solution for this, but I haven't found one. I've been disabling several rules which conflict in this case but disabling them caused other issues. The only way to fix this was writing it differently:

<?php

function test()
{
    query(
        '
            INSERT INTO table (column)
            VALUES (:value)
        ',
        [
            'value' => $value,
        ]
    );
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants