diff --git a/rules/DeadCode/PhpDoc/DeadReturnTagValueNodeAnalyzer.php b/rules/DeadCode/PhpDoc/DeadReturnTagValueNodeAnalyzer.php index 8a9aaf748422..8051fcd209f1 100644 --- a/rules/DeadCode/PhpDoc/DeadReturnTagValueNodeAnalyzer.php +++ b/rules/DeadCode/PhpDoc/DeadReturnTagValueNodeAnalyzer.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace Rector\DeadCode\PhpDoc; +use PhpParser\Node\Identifier; use PhpParser\Node\Stmt\ClassMethod; use PHPStan\Analyser\Scope; use PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode; @@ -63,6 +64,10 @@ public function isDead(ReturnTagValueNode $returnTagValueNode, ClassMethod $clas if ($scope instanceof Scope && $scope->isInTrait() && $returnTagValueNode->type instanceof ThisTypeNode) { return \false; } + // in case of void, there is no added value in @return tag + if ($returnType instanceof Identifier && $returnType->toString() === 'void') { + return \true; + } if (!$this->typeComparator->arePhpParserAndPhpStanPhpDocTypesEqual($returnType, $returnTagValueNode->type, $classMethod)) { return $returnTagValueNode->type instanceof IdentifierTypeNode && (string) $returnTagValueNode->type === 'void'; } diff --git a/rules/Php71/Rector/FuncCall/CountOnNullRector.php b/rules/Php71/Rector/FuncCall/CountOnNullRector.php deleted file mode 100644 index 422b2e55298f..000000000000 --- a/rules/Php71/Rector/FuncCall/CountOnNullRector.php +++ /dev/null @@ -1,51 +0,0 @@ -> - */ - public function getNodeTypes() : array - { - return [FuncCall::class, Ternary::class]; - } - /** - * @param FuncCall|Ternary $node - * @return int|\PhpParser\Node\Expr\Ternary|null|\PhpParser\Node\Expr\FuncCall - */ - public function refactorWithScope(Node $node, Scope $scope) - { - \trigger_error(\sprintf('The "%s" rule is now deprecated as often reports false positives and requires custom refactoring of previous code. Use PHPStan to spot nullable arguments and refactor code to fit your use case.', self::class), \E_USER_ERROR); - } -} diff --git a/rules/TypeDeclaration/Rector/Property/TypedPropertyFromStrictGetterMethodReturnTypeRector.php b/rules/TypeDeclaration/Rector/Property/TypedPropertyFromStrictGetterMethodReturnTypeRector.php deleted file mode 100644 index ff450d5d00f3..000000000000 --- a/rules/TypeDeclaration/Rector/Property/TypedPropertyFromStrictGetterMethodReturnTypeRector.php +++ /dev/null @@ -1,59 +0,0 @@ -name; - } -} -CODE_SAMPLE -, <<<'CODE_SAMPLE' -final class SomeClass -{ - public ?string $name = null; - - public function getName(): string|null - { - return $this->name; - } -} -CODE_SAMPLE -)]); - } - /** - * @return array> - */ - public function getNodeTypes() : array - { - return [Class_::class]; - } - /** - * @param Class_ $node - */ - public function refactor(Node $node) : ?\PhpParser\Node\Stmt\Class_ - { - \trigger_error('This rule is deprecated as created invalid code. Use other rules from TYPE_DECLARATION instead'); - \sleep(3); - return null; - } -} diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index 823d7f7076f2..992980d98c56 100644 --- a/src/Application/VersionResolver.php +++ b/src/Application/VersionResolver.php @@ -19,12 +19,12 @@ final class VersionResolver * @api * @var string */ - public const PACKAGE_VERSION = 'b8e6818ed04f3aa07218569509bd819db3649820'; + public const PACKAGE_VERSION = '026398c9e1078cb3ac5cac41767b620872166859'; /** * @api * @var string */ - public const RELEASE_DATE = '2023-12-03 18:41:40'; + public const RELEASE_DATE = '2023-12-03 20:08:03'; /** * @var int */ diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php index 89e2b237c580..e7d2dc09088a 100644 --- a/vendor/composer/autoload_classmap.php +++ b/vendor/composer/autoload_classmap.php @@ -1808,7 +1808,6 @@ 'Rector\\Php71\\Rector\\BinaryOp\\BinaryOpBetweenNumberAndStringRector' => $baseDir . '/rules/Php71/Rector/BinaryOp/BinaryOpBetweenNumberAndStringRector.php', 'Rector\\Php71\\Rector\\BooleanOr\\IsIterableRector' => $baseDir . '/rules/Php71/Rector/BooleanOr/IsIterableRector.php', 'Rector\\Php71\\Rector\\ClassConst\\PublicConstantVisibilityRector' => $baseDir . '/rules/Php71/Rector/ClassConst/PublicConstantVisibilityRector.php', - 'Rector\\Php71\\Rector\\FuncCall\\CountOnNullRector' => $baseDir . '/rules/Php71/Rector/FuncCall/CountOnNullRector.php', 'Rector\\Php71\\Rector\\FuncCall\\RemoveExtraParametersRector' => $baseDir . '/rules/Php71/Rector/FuncCall/RemoveExtraParametersRector.php', 'Rector\\Php71\\Rector\\List_\\ListToArrayDestructRector' => $baseDir . '/rules/Php71/Rector/List_/ListToArrayDestructRector.php', 'Rector\\Php71\\Rector\\TryCatch\\MultiExceptionCatchRector' => $baseDir . '/rules/Php71/Rector/TryCatch/MultiExceptionCatchRector.php', @@ -2340,7 +2339,6 @@ 'Rector\\TypeDeclaration\\Rector\\Property\\AddPropertyTypeDeclarationRector' => $baseDir . '/rules/TypeDeclaration/Rector/Property/AddPropertyTypeDeclarationRector.php', 'Rector\\TypeDeclaration\\Rector\\Property\\TypedPropertyFromAssignsRector' => $baseDir . '/rules/TypeDeclaration/Rector/Property/TypedPropertyFromAssignsRector.php', 'Rector\\TypeDeclaration\\Rector\\Property\\TypedPropertyFromStrictConstructorRector' => $baseDir . '/rules/TypeDeclaration/Rector/Property/TypedPropertyFromStrictConstructorRector.php', - 'Rector\\TypeDeclaration\\Rector\\Property\\TypedPropertyFromStrictGetterMethodReturnTypeRector' => $baseDir . '/rules/TypeDeclaration/Rector/Property/TypedPropertyFromStrictGetterMethodReturnTypeRector.php', 'Rector\\TypeDeclaration\\Rector\\Property\\TypedPropertyFromStrictSetUpRector' => $baseDir . '/rules/TypeDeclaration/Rector/Property/TypedPropertyFromStrictSetUpRector.php', 'Rector\\TypeDeclaration\\Rector\\StmtsAwareInterface\\DeclareStrictTypesRector' => $baseDir . '/rules/TypeDeclaration/Rector/StmtsAwareInterface/DeclareStrictTypesRector.php', 'Rector\\TypeDeclaration\\Rector\\While_\\WhileNullableToInstanceofRector' => $baseDir . '/rules/TypeDeclaration/Rector/While_/WhileNullableToInstanceofRector.php', diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 5a4935d202de..5b18162c96f7 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -2026,7 +2026,6 @@ class ComposerStaticInita55c41c7fa52abd86138c6f32df1d185 'Rector\\Php71\\Rector\\BinaryOp\\BinaryOpBetweenNumberAndStringRector' => __DIR__ . '/../..' . '/rules/Php71/Rector/BinaryOp/BinaryOpBetweenNumberAndStringRector.php', 'Rector\\Php71\\Rector\\BooleanOr\\IsIterableRector' => __DIR__ . '/../..' . '/rules/Php71/Rector/BooleanOr/IsIterableRector.php', 'Rector\\Php71\\Rector\\ClassConst\\PublicConstantVisibilityRector' => __DIR__ . '/../..' . '/rules/Php71/Rector/ClassConst/PublicConstantVisibilityRector.php', - 'Rector\\Php71\\Rector\\FuncCall\\CountOnNullRector' => __DIR__ . '/../..' . '/rules/Php71/Rector/FuncCall/CountOnNullRector.php', 'Rector\\Php71\\Rector\\FuncCall\\RemoveExtraParametersRector' => __DIR__ . '/../..' . '/rules/Php71/Rector/FuncCall/RemoveExtraParametersRector.php', 'Rector\\Php71\\Rector\\List_\\ListToArrayDestructRector' => __DIR__ . '/../..' . '/rules/Php71/Rector/List_/ListToArrayDestructRector.php', 'Rector\\Php71\\Rector\\TryCatch\\MultiExceptionCatchRector' => __DIR__ . '/../..' . '/rules/Php71/Rector/TryCatch/MultiExceptionCatchRector.php', @@ -2558,7 +2557,6 @@ class ComposerStaticInita55c41c7fa52abd86138c6f32df1d185 'Rector\\TypeDeclaration\\Rector\\Property\\AddPropertyTypeDeclarationRector' => __DIR__ . '/../..' . '/rules/TypeDeclaration/Rector/Property/AddPropertyTypeDeclarationRector.php', 'Rector\\TypeDeclaration\\Rector\\Property\\TypedPropertyFromAssignsRector' => __DIR__ . '/../..' . '/rules/TypeDeclaration/Rector/Property/TypedPropertyFromAssignsRector.php', 'Rector\\TypeDeclaration\\Rector\\Property\\TypedPropertyFromStrictConstructorRector' => __DIR__ . '/../..' . '/rules/TypeDeclaration/Rector/Property/TypedPropertyFromStrictConstructorRector.php', - 'Rector\\TypeDeclaration\\Rector\\Property\\TypedPropertyFromStrictGetterMethodReturnTypeRector' => __DIR__ . '/../..' . '/rules/TypeDeclaration/Rector/Property/TypedPropertyFromStrictGetterMethodReturnTypeRector.php', 'Rector\\TypeDeclaration\\Rector\\Property\\TypedPropertyFromStrictSetUpRector' => __DIR__ . '/../..' . '/rules/TypeDeclaration/Rector/Property/TypedPropertyFromStrictSetUpRector.php', 'Rector\\TypeDeclaration\\Rector\\StmtsAwareInterface\\DeclareStrictTypesRector' => __DIR__ . '/../..' . '/rules/TypeDeclaration/Rector/StmtsAwareInterface/DeclareStrictTypesRector.php', 'Rector\\TypeDeclaration\\Rector\\While_\\WhileNullableToInstanceofRector' => __DIR__ . '/../..' . '/rules/TypeDeclaration/Rector/While_/WhileNullableToInstanceofRector.php',