diff --git a/src/TokenRunner/Analyzer/FixerAnalyzer/BlockFinder.php b/src/TokenRunner/Analyzer/FixerAnalyzer/BlockFinder.php index 1ee08a961..f00eb166d 100644 --- a/src/TokenRunner/Analyzer/FixerAnalyzer/BlockFinder.php +++ b/src/TokenRunner/Analyzer/FixerAnalyzer/BlockFinder.php @@ -61,6 +61,17 @@ public function findInTokensByEdge(Tokens $tokens, int $position): ?BlockInfo if ($token->equals(';')) { return null; } + + if ($position !== null && $token->equals('(')) { + $closingPosition = $tokens->getNextMeaningfulToken($position); + if ($closingPosition !== null) { + $closingToken = $tokens[$closingPosition]; + if ($closingToken->equals(')')) { + // function has no arguments + return null; + } + } + } } // some invalid code diff --git a/tests/Fixer/Spacing/StandaloneLineConstructorParamFixer/Fixture/empty_constructor.php.inc b/tests/Fixer/Spacing/StandaloneLineConstructorParamFixer/Fixture/empty_constructor.php.inc new file mode 100644 index 000000000..ea1911e5d --- /dev/null +++ b/tests/Fixer/Spacing/StandaloneLineConstructorParamFixer/Fixture/empty_constructor.php.inc @@ -0,0 +1,13 @@ +