There is an issue if we declare only two variables with the equals sign aligned. It returns the error message:"Equals sign not aligned with surrounding assignments; expected X but found Y" where X and Y vary depending on the spaces we have.

Ex:

$my_first_variable  = 'some value';
$my_second_variable = 'another value';

This code returns a false positive.

If there are three or more variables with the equal sign aligned, this error does not happen.

Comments

yuriseki created an issue. See original summary.

yseki’s picture

StatusFileSize
new856 bytes

Here is the patch.

yseki’s picture

Issue summary: View changes
yseki’s picture

StatusFileSize
new2.5 KB

A better patch.

yseki’s picture

Status: Active » Needs review
klausi’s picture

Version: 8.x-2.x-dev » 8.x-3.x-dev
Status: Needs review » Needs work
Issue tags: +Needs tests

Interesting, can you check again with Coder 8.x-3.x?

Can you also add a test case and file this as pull request against https://github.com/pfrenssen/coder/pulls ?

Thanks!

ralkeon’s picture

Hi! I can confirm, still doesn't work in 3.x-dev but the #4 patch works!

In my case I had 2 variables like

$variable1 = 1;
$variables2 = 2;

the first had 2 spaces, the alignment was right but coder recognize as a non-standard code.

With the patch all goes well.

  • klausi committed 4d110e4 on 8.x-3.x
    fix(MultipleStatementAlignment): Fix false positive when equal sign...
klausi’s picture

Status: Needs work » Fixed
Issue tags: -Needs tests

I ended up using a different fix for the sniff, thanks for providing the patch anyway!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.