From a373054b2d9bd88e39deb9c098b5d7a9d5746c2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Wer=C5=82os?= Date: Fri, 19 Jun 2020 16:39:33 +0200 Subject: [PATCH] PhpdocToParamTypeFixer - fix for void as param --- .../FunctionNotation/PhpdocToParamTypeFixer.php | 14 ++------------ .../PhpdocToParamTypeFixerTest.php | 3 +++ 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/Fixer/FunctionNotation/PhpdocToParamTypeFixer.php b/src/Fixer/FunctionNotation/PhpdocToParamTypeFixer.php index 07b5d5d46f8..ad6c04dfb3a 100644 --- a/src/Fixer/FunctionNotation/PhpdocToParamTypeFixer.php +++ b/src/Fixer/FunctionNotation/PhpdocToParamTypeFixer.php @@ -52,6 +52,7 @@ final class PhpdocToParamTypeFixer extends AbstractFixer implements Configuratio 'mixed' => true, 'resource' => true, 'static' => true, + 'void' => true, ]; /** @@ -157,7 +158,6 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens) $hasIterable = false; $hasNull = false; - $hasVoid = false; $hasArray = false; $hasString = false; $hasInt = false; @@ -189,11 +189,6 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens) $minimumTokenPhpVersion = 70100; } - if ('void' === $type) { - $hasVoid = true; - unset($types[$key]); - } - if ('string' === $type) { $hasString = true; unset($types[$key]); @@ -270,7 +265,6 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens) $hasNull, $hasArray, $hasIterable, - $hasVoid, $hasString, $hasInt, $hasFloat, @@ -358,7 +352,6 @@ private function hasParamTypeHint(Tokens $tokens, $index) * @param bool $hasNull * @param bool $hasArray * @param bool $hasIterable - * @param bool $hasVoid * @param bool $hasString * @param bool $hasInt * @param bool $hasFloat @@ -373,7 +366,6 @@ private function fixFunctionDefinition( $hasNull, $hasArray, $hasIterable, - $hasVoid, $hasString, $hasInt, $hasFloat, @@ -383,9 +375,7 @@ private function fixFunctionDefinition( ) { $newTokens = []; - if (true === $hasVoid) { - $newTokens[] = new Token('void'); - } elseif (true === $hasIterable && true === $hasArray) { + if (true === $hasIterable && true === $hasArray) { $newTokens[] = new Token([CT::T_ARRAY_TYPEHINT, 'array']); } elseif (true === $hasIterable) { $newTokens[] = new Token([T_STRING, 'iterable']); diff --git a/tests/Fixer/FunctionNotation/PhpdocToParamTypeFixerTest.php b/tests/Fixer/FunctionNotation/PhpdocToParamTypeFixerTest.php index de0db950586..f8e3b709d44 100644 --- a/tests/Fixer/FunctionNotation/PhpdocToParamTypeFixerTest.php +++ b/tests/Fixer/FunctionNotation/PhpdocToParamTypeFixerTest.php @@ -328,6 +328,9 @@ class Foo { ' [ + '