function RequireConstructorPropertyPromotionSniff::isParameterModifiedBeforeAssignment
1 call to RequireConstructorPropertyPromotionSniff::isParameterModifiedBeforeAssignment()
- RequireConstructorPropertyPromotionSniff::process in vendor/
slevomat/ coding-standard/ SlevomatCodingStandard/ Sniffs/ Classes/ RequireConstructorPropertyPromotionSniff.php - * @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint *
File
-
vendor/
slevomat/ coding-standard/ SlevomatCodingStandard/ Sniffs/ Classes/ RequireConstructorPropertyPromotionSniff.php, line 362
Class
Namespace
SlevomatCodingStandard\Sniffs\ClassesCode
private function isParameterModifiedBeforeAssignment(File $phpcsFile, int $functionPointer, string $parameterName, int $assignmentPointer) : bool {
$tokens = $phpcsFile->getTokens();
for ($i = $assignmentPointer - 1; $i > $tokens[$functionPointer]['scope_opener']; $i--) {
if ($tokens[$i]['code'] !== T_VARIABLE) {
continue;
}
if ($tokens[$i]['content'] !== $parameterName) {
continue;
}
$nextPointer = TokenHelper::findNextEffective($phpcsFile, $i + 1);
if (in_array($tokens[$nextPointer]['code'], Tokens::$assignmentTokens, true)) {
return true;
}
if ($tokens[$nextPointer]['code'] === T_INC) {
return true;
}
$previousPointer = TokenHelper::findNextEffective($phpcsFile, $i - 1);
if ($tokens[$previousPointer]['code'] === T_DEC) {
return true;
}
}
return false;
}