Skip to content

Commit

Permalink
PHP 8.0 | Squiz.WhiteSpace.MemberVarSpacing: fix support for attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
javer committed Sep 24, 2021
1 parent b10c327 commit a247461
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ protected function processMemberVar(File $phpcsFile, $stackPtr)
if ($tokens[$prev]['code'] === T_ATTRIBUTE_END
&& isset($tokens[$prev]['attribute_opener']) === true
) {
$prev = $tokens[$prev]['attribute_opener'];
$prev = $tokens[$prev]['attribute_opener'];
$start = $prev;
continue;
}

Expand Down Expand Up @@ -140,7 +141,7 @@ protected function processMemberVar(File $phpcsFile, $stackPtr)
$first = $tokens[$start]['comment_opener'];
} else {
$first = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($start - 1), null, true);
$first = $phpcsFile->findNext(Tokens::$commentTokens, ($first + 1));
$first = $phpcsFile->findNext(array_merge(Tokens::$commentTokens, [T_ATTRIBUTE]), ($first + 1));
}

// Determine if this is the first member var.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,4 +355,13 @@ class HasAttributes

#[ORM\Column(ORM\Column::T_INTEGER)]
protected $height;

#[SingleAttribute]
protected $propertySingle;

#[FirstAttribute]
#[SecondAttribute]
protected $propertyDouble;
#[ThirdAttribute]
protected $propertyWithoutSpacing;
}
Original file line number Diff line number Diff line change
Expand Up @@ -339,4 +339,14 @@ class HasAttributes
#[ORM\GeneratedValue]
#[ORM\Column(ORM\Column::T_INTEGER)]
protected $height;

#[SingleAttribute]
protected $propertySingle;

#[FirstAttribute]
#[SecondAttribute]
protected $propertyDouble;

#[ThirdAttribute]
protected $propertyWithoutSpacing;
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public function getErrorList()
346 => 1,
353 => 1,
357 => 1,
366 => 1,
];

}//end getErrorList()
Expand Down

0 comments on commit a247461

Please sign in to comment.