Skip to content

Commit

Permalink
Add fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kubawerlos committed Nov 27, 2023
1 parent 6469cab commit 882547e
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/Fixer/FunctionNotation/NoSpacesAfterFunctionNameFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function getPriority(): int

public function isCandidate(Tokens $tokens): bool
{
return $tokens->isAnyTokenKindsFound(array_merge($this->getFunctionyTokenKinds(), [T_STRING]));
return $tokens->isAnyTokenKindsFound([T_STRING, ...$this->getFunctionyTokenKinds()]);
}

protected function applyFix(\SplFileInfo $file, Tokens $tokens): void
Expand All @@ -73,7 +73,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void
$nextNonWhiteSpace = $tokens->getNextMeaningfulToken($endParenthesisIndex);
if (
null !== $nextNonWhiteSpace
&& $tokens[$nextNonWhiteSpace]->equals('?')
&& !$tokens[$nextNonWhiteSpace]->equals(';')
&& $tokens[$lastTokenIndex]->isGivenKind($languageConstructionTokens)
) {
continue;
Expand All @@ -82,10 +82,6 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void
// check if it is a function call
if ($tokens[$lastTokenIndex]->isGivenKind($functionyTokens)) {
$this->fixFunctionCall($tokens, $index);
} elseif ($tokens[$lastTokenIndex]->isGivenKind(T_ECHO)) {
if ($tokens[$nextNonWhiteSpace]->equals(';')) {
$this->fixFunctionCall($tokens, $index);
}
} elseif ($tokens[$lastTokenIndex]->isGivenKind(T_STRING)) { // for real function calls or definitions
$possibleDefinitionIndex = $tokens->getPrevMeaningfulToken($lastTokenIndex);
if (!$tokens[$possibleDefinitionIndex]->isGivenKind(T_FUNCTION)) {
Expand Down Expand Up @@ -143,6 +139,7 @@ private function getFunctionyTokenKinds(): array
{
static $tokens = [
T_ARRAY,
T_ECHO,
T_EMPTY,
T_EVAL,
T_EXIT,
Expand All @@ -168,6 +165,7 @@ private function getFunctionyTokenKinds(): array
private function getLanguageConstructionTokenKinds(): array
{
static $languageConstructionTokens = [
T_ECHO,
T_PRINT,
T_INCLUDE,
T_INCLUDE_ONCE,
Expand Down

0 comments on commit 882547e

Please sign in to comment.