From 1095b54b14d6f9adebd15783b8739faf8c56361a Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Mon, 4 Dec 2023 14:56:20 +0000 Subject: [PATCH] Updated Rector to commit 005ccc330c3bb37f9faf0f5e2c319036f2d055b8 https://github.com/rectorphp/rector-src/commit/005ccc330c3bb37f9faf0f5e2c319036f2d055b8 Rectify (#5324) --- docs/rector_rules_overview.md | 58 ++++++------------- .../PhpDoc/DeadReturnTagValueNodeAnalyzer.php | 12 ++-- .../Rector/If_/RemoveDeadInstanceOfRector.php | 4 +- src/Application/VersionResolver.php | 4 +- 4 files changed, 27 insertions(+), 51 deletions(-) diff --git a/docs/rector_rules_overview.md b/docs/rector_rules_overview.md index 7301dfb8cbe..829d4589815 100644 --- a/docs/rector_rules_overview.md +++ b/docs/rector_rules_overview.md @@ -1,4 +1,4 @@ -# 353 Rules Overview +# 351 Rules Overview
@@ -6,7 +6,7 @@ - [Arguments](#arguments) (4) -- [CodeQuality](#codequality) (72) +- [CodeQuality](#codequality) (73) - [CodingStyle](#codingstyle) (27) @@ -30,7 +30,7 @@ - [Php70](#php70) (19) -- [Php71](#php71) (8) +- [Php71](#php71) (7) - [Php72](#php72) (9) @@ -56,7 +56,7 @@ - [Transform](#transform) (22) -- [TypeDeclaration](#typedeclaration) (40) +- [TypeDeclaration](#typedeclaration) (39) - [Visibility](#visibility) (3) @@ -942,6 +942,19 @@ Remove `sprintf()` wrapper if not needed
+### RemoveUselessIsObjectCheckRector + +Remove useless `is_object()` check on combine with instanceof check + +- class: [`Rector\CodeQuality\Rector\BooleanAnd\RemoveUselessIsObjectCheckRector`](../rules/CodeQuality/Rector/BooleanAnd/RemoveUselessIsObjectCheckRector.php) + +```diff +-is_object($obj) && $obj instanceof DateTime ++$obj instanceof DateTime +``` + +
+ ### ReplaceMultipleBooleanNotRector Replace the Double not operator (!!) by type-casting to boolean @@ -3818,7 +3831,7 @@ Changes PHP 4 style constructor to __construct. ### RandomFunctionRector -Changes rand, srand, mt_rand and getrandmax to newer alternatives. +Changes rand, srand, and getrandmax to newer alternatives - class: [`Rector\Php70\Rector\FuncCall\RandomFunctionRector`](../rules/Php70/Rector/FuncCall/RandomFunctionRector.php) @@ -4005,20 +4018,6 @@ Change binary operation between some number + string to PHP 7.1 compatible versi
-### CountOnNullRector - -Changes `count()` on null to safe ternary check - -- class: [`Rector\Php71\Rector\FuncCall\CountOnNullRector`](../rules/Php71/Rector/FuncCall/CountOnNullRector.php) - -```diff - $values = null; --$count = count($values); -+$count = $values === null ? 0 : count($values); -``` - -
- ### IsIterableRector Changes is_array + Traversable check to is_iterable @@ -6990,27 +6989,6 @@ Add typed properties based only on strict constructor types
-### TypedPropertyFromStrictGetterMethodReturnTypeRector - -Complete property type based on getter strict types - -- class: [`Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictGetterMethodReturnTypeRector`](../rules/TypeDeclaration/Rector/Property/TypedPropertyFromStrictGetterMethodReturnTypeRector.php) - -```diff - final class SomeClass - { -- public $name; -+ public ?string $name = null; - - public function getName(): string|null - { - return $this->name; - } - } -``` - -
- ### TypedPropertyFromStrictSetUpRector Add strict typed property based on `setUp()` strict typed assigns in TestCase diff --git a/rules/DeadCode/PhpDoc/DeadReturnTagValueNodeAnalyzer.php b/rules/DeadCode/PhpDoc/DeadReturnTagValueNodeAnalyzer.php index f7c71a5174b..f342ec2f2d6 100644 --- a/rules/DeadCode/PhpDoc/DeadReturnTagValueNodeAnalyzer.php +++ b/rules/DeadCode/PhpDoc/DeadReturnTagValueNodeAnalyzer.php @@ -3,8 +3,8 @@ declare (strict_types=1); namespace Rector\DeadCode\PhpDoc; -use PhpParser\Node\Identifier; use PhpParser\Node; +use PhpParser\Node\Identifier; use PhpParser\Node\Stmt\ClassMethod; use PHPStan\Analyser\Scope; use PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode; @@ -131,14 +131,12 @@ final class DeadReturnTagValueNodeAnalyzer */ private function hasUsefullPhpdocType(ReturnTagValueNode $returnTagValueNode, $returnType) : bool { - if ($this->isVoidReturnType($returnType)) { - if (!$returnTagValueNode->type instanceof IdentifierTypeNode || (string) $returnTagValueNode->type !== 'never') { - return \false; - } + if (!$this->isVoidReturnType($returnType)) { + return !$this->isNeverReturnType($returnType); } - if ($this->isNeverReturnType($returnType)) { + if (!$returnTagValueNode->type instanceof IdentifierTypeNode || (string) $returnTagValueNode->type !== 'never') { return \false; } - return \true; + return !$this->isNeverReturnType($returnType); } } diff --git a/rules/DeadCode/Rector/If_/RemoveDeadInstanceOfRector.php b/rules/DeadCode/Rector/If_/RemoveDeadInstanceOfRector.php index 145caa986f6..3ea3118531e 100644 --- a/rules/DeadCode/Rector/If_/RemoveDeadInstanceOfRector.php +++ b/rules/DeadCode/Rector/If_/RemoveDeadInstanceOfRector.php @@ -3,10 +3,9 @@ declare (strict_types=1); namespace Rector\DeadCode\Rector\If_; -use PhpParser\Node\Expr\Assign; -use PhpParser\Node\Stmt\Expression; use PhpParser\Node; use PhpParser\Node\Expr; +use PhpParser\Node\Expr\Assign; use PhpParser\Node\Expr\BooleanNot; use PhpParser\Node\Expr\CallLike; use PhpParser\Node\Expr\Instanceof_; @@ -14,6 +13,7 @@ use PhpParser\Node\Expr\PropertyFetch; use PhpParser\Node\Expr\StaticPropertyFetch; use PhpParser\Node\Name; use PhpParser\Node\Stmt; +use PhpParser\Node\Stmt\Expression; use PhpParser\Node\Stmt\If_; use PhpParser\NodeTraverser; use PHPStan\Type\MixedType; diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index aea93fbd486..238959f5caf 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 = '526f4cd09c06842987e46d661b6ad87a8da723a7'; + public const PACKAGE_VERSION = '005ccc330c3bb37f9faf0f5e2c319036f2d055b8'; /** * @api * @var string */ - public const RELEASE_DATE = '2023-12-04 21:48:50'; + public const RELEASE_DATE = '2023-12-04 21:54:02'; /** * @var int */