diff --git a/build/target-repository/docs/rector_rules_overview.md b/build/target-repository/docs/rector_rules_overview.md index 5172db9914e..c56313feedf 100644 --- a/build/target-repository/docs/rector_rules_overview.md +++ b/build/target-repository/docs/rector_rules_overview.md @@ -1,4 +1,4 @@ -# 406 Rules Overview +# 405 Rules Overview
@@ -8,7 +8,7 @@ - [CodeQuality](#codequality) (76) -- [CodingStyle](#codingstyle) (35) +- [CodingStyle](#codingstyle) (34) - [Compatibility](#compatibility) (1) @@ -1865,25 +1865,6 @@ Adds array default value to property to prevent foreach over null error
-### AddFalseDefaultToBoolPropertyRector - -Add false default to bool properties, to prevent null compare errors - -- class: [`Rector\CodingStyle\Rector\Property\AddFalseDefaultToBoolPropertyRector`](../rules/CodingStyle/Rector/Property/AddFalseDefaultToBoolPropertyRector.php) - -```diff - class SomeClass - { - /** - * @var bool - */ -- private $isDisabled; -+ private $isDisabled = false; - } -``` - -
- ### BinarySwitchToIfElseRector Changes switch with 2 options to if-else diff --git a/config/set/coding-style.php b/config/set/coding-style.php index e62c655394b..23f5130a26d 100644 --- a/config/set/coding-style.php +++ b/config/set/coding-style.php @@ -25,7 +25,6 @@ use Rector\CodingStyle\Rector\If_\NullableCompareToNullRector; use Rector\CodingStyle\Rector\Plus\UseIncrementAssignRector; use Rector\CodingStyle\Rector\PostInc\PostIncDecToPreIncDecRector; -use Rector\CodingStyle\Rector\Property\AddFalseDefaultToBoolPropertyRector; use Rector\CodingStyle\Rector\Property\SplitGroupedPropertiesRector; use Rector\CodingStyle\Rector\Stmt\NewlineAfterStatementRector; use Rector\CodingStyle\Rector\String_\SymplifyQuoteEscapeRector; @@ -64,7 +63,6 @@ WrapEncapsedVariableInCurlyBracesRector::class, NewlineBeforeNewAssignSetRector::class, AddArrayDefaultToArrayPropertyRector::class, - AddFalseDefaultToBoolPropertyRector::class, MakeInheritedMethodVisibilitySameAsParentRector::class, CallUserFuncArrayToVariadicRector::class, VersionCompareFuncCallToConstantRector::class, diff --git a/rules-tests/CodingStyle/Rector/Property/AddFalseDefaultToBoolPropertyRector/AddFalseDefaultToBoolPropertyRectorTest.php b/rules-tests/CodingStyle/Rector/Property/AddFalseDefaultToBoolPropertyRector/AddFalseDefaultToBoolPropertyRectorTest.php deleted file mode 100644 index 251d08696ca..00000000000 --- a/rules-tests/CodingStyle/Rector/Property/AddFalseDefaultToBoolPropertyRector/AddFalseDefaultToBoolPropertyRectorTest.php +++ /dev/null @@ -1,28 +0,0 @@ -doTestFile($filePath); - } - - public static function provideData(): Iterator - { - return self::yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - public function provideConfigFilePath(): string - { - return __DIR__ . '/config/configured_rule.php'; - } -} diff --git a/rules-tests/CodingStyle/Rector/Property/AddFalseDefaultToBoolPropertyRector/Fixture/fixture.php.inc b/rules-tests/CodingStyle/Rector/Property/AddFalseDefaultToBoolPropertyRector/Fixture/fixture.php.inc deleted file mode 100644 index 8aaf1e13a08..00000000000 --- a/rules-tests/CodingStyle/Rector/Property/AddFalseDefaultToBoolPropertyRector/Fixture/fixture.php.inc +++ /dev/null @@ -1,27 +0,0 @@ - ------ - diff --git a/rules-tests/CodingStyle/Rector/Property/AddFalseDefaultToBoolPropertyRector/Fixture/skip_assigned_in_construct.php.inc b/rules-tests/CodingStyle/Rector/Property/AddFalseDefaultToBoolPropertyRector/Fixture/skip_assigned_in_construct.php.inc deleted file mode 100644 index 40ff62d7171..00000000000 --- a/rules-tests/CodingStyle/Rector/Property/AddFalseDefaultToBoolPropertyRector/Fixture/skip_assigned_in_construct.php.inc +++ /dev/null @@ -1,16 +0,0 @@ -property = $property; - } -} diff --git a/rules-tests/CodingStyle/Rector/Property/AddFalseDefaultToBoolPropertyRector/Fixture/skip_assigned_in_construct2.php.inc b/rules-tests/CodingStyle/Rector/Property/AddFalseDefaultToBoolPropertyRector/Fixture/skip_assigned_in_construct2.php.inc deleted file mode 100644 index 0699b7a9dbb..00000000000 --- a/rules-tests/CodingStyle/Rector/Property/AddFalseDefaultToBoolPropertyRector/Fixture/skip_assigned_in_construct2.php.inc +++ /dev/null @@ -1,16 +0,0 @@ -property = $property; - } -} diff --git a/rules-tests/CodingStyle/Rector/Property/AddFalseDefaultToBoolPropertyRector/Fixture/skip_default.php.inc b/rules-tests/CodingStyle/Rector/Property/AddFalseDefaultToBoolPropertyRector/Fixture/skip_default.php.inc deleted file mode 100644 index e9b3624fd16..00000000000 --- a/rules-tests/CodingStyle/Rector/Property/AddFalseDefaultToBoolPropertyRector/Fixture/skip_default.php.inc +++ /dev/null @@ -1,11 +0,0 @@ -rule(AddFalseDefaultToBoolPropertyRector::class); -}; diff --git a/rules/CodingStyle/Rector/Property/AddFalseDefaultToBoolPropertyRector.php b/rules/CodingStyle/Rector/Property/AddFalseDefaultToBoolPropertyRector.php deleted file mode 100644 index cf03b53d427..00000000000 --- a/rules/CodingStyle/Rector/Property/AddFalseDefaultToBoolPropertyRector.php +++ /dev/null @@ -1,106 +0,0 @@ -> - */ - public function getNodeTypes(): array - { - return [Property::class]; - } - - /** - * @param Property $node - */ - public function refactor(Node $node): ?Node - { - if (count($node->props) !== 1) { - return null; - } - - $onlyProperty = $node->props[0]; - if ($onlyProperty->default instanceof Expr) { - return null; - } - - if (! $this->isBoolDocType($node)) { - return null; - } - - $classLike = $this->betterNodeFinder->findParentByTypes($node, [Class_::class, Trait_::class]); - - if (! $classLike instanceof ClassLike) { - return null; - } - - $propertyName = $this->nodeNameResolver->getName($onlyProperty); - if ($this->constructorAssignDetector->isPropertyAssigned($classLike, $propertyName)) { - return null; - } - - $onlyProperty->default = $this->nodeFactory->createFalse(); - return $node; - } - - private function isBoolDocType(Property $property): bool - { - $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($property); - return $phpDocInfo->getVarType() - ->isBoolean() - ->yes(); - } -} diff --git a/rules/DeadCode/Rector/ClassMethod/RemoveUnusedPrivateMethodRector.php b/rules/DeadCode/Rector/ClassMethod/RemoveUnusedPrivateMethodRector.php index 11034ec7469..c1e075e3d0b 100644 --- a/rules/DeadCode/Rector/ClassMethod/RemoveUnusedPrivateMethodRector.php +++ b/rules/DeadCode/Rector/ClassMethod/RemoveUnusedPrivateMethodRector.php @@ -11,7 +11,6 @@ use PhpParser\Node\Stmt\ClassMethod; use PHPStan\Analyser\Scope; use PHPStan\Reflection\ClassReflection; -use Rector\Core\Rector\AbstractRector; use Rector\Core\Rector\AbstractScopeAwareRector; use Rector\Core\Reflection\ReflectionResolver; use Rector\Core\ValueObject\MethodName;