diff --git a/build/target-repository/docs/rector_rules_overview.md b/build/target-repository/docs/rector_rules_overview.md index 7301dfb8cbe..829d4589815 100644 --- a/build/target-repository/docs/rector_rules_overview.md +++ b/build/target-repository/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/packages/Testing/PHPUnit/AbstractRectorTestCase.php b/packages/Testing/PHPUnit/AbstractRectorTestCase.php index e523597ca2b..0db91556d62 100644 --- a/packages/Testing/PHPUnit/AbstractRectorTestCase.php +++ b/packages/Testing/PHPUnit/AbstractRectorTestCase.php @@ -205,7 +205,7 @@ private function includePreloadFilesAndScoperAutoload(): void if (file_exists(__DIR__ . '/../../../preload.php')) { if (file_exists(__DIR__ . '/../../../vendor')) { require_once __DIR__ . '/../../../preload.php'; - // test case in rector split package + // test case in rector split package } elseif (file_exists(__DIR__ . '/../../../../../../vendor')) { require_once __DIR__ . '/../../../preload-split-package.php'; } diff --git a/rules/DeadCode/PhpDoc/DeadReturnTagValueNodeAnalyzer.php b/rules/DeadCode/PhpDoc/DeadReturnTagValueNodeAnalyzer.php index f7e5801ac7d..e3d151e4ede 100644 --- a/rules/DeadCode/PhpDoc/DeadReturnTagValueNodeAnalyzer.php +++ b/rules/DeadCode/PhpDoc/DeadReturnTagValueNodeAnalyzer.php @@ -4,8 +4,8 @@ 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; @@ -50,7 +50,7 @@ public function isDead(ReturnTagValueNode $returnTagValueNode, ClassMethod $clas return false; } - if (!$this->hasUsefullPhpdocType($returnTagValueNode, $returnType)) { + if (! $this->hasUsefullPhpdocType($returnTagValueNode, $returnType)) { return true; } @@ -132,15 +132,14 @@ private function hasTrueFalsePseudoType(BracketsAwareUnionTypeNode $bracketsAwar */ private function hasUsefullPhpdocType(ReturnTagValueNode $returnTagValueNode, mixed $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 7cbc0b27954..c1956b8eaa3 100644 --- a/rules/DeadCode/Rector/If_/RemoveDeadInstanceOfRector.php +++ b/rules/DeadCode/Rector/If_/RemoveDeadInstanceOfRector.php @@ -4,10 +4,9 @@ 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_; @@ -15,6 +14,7 @@ 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;