diff --git a/config/set/strict-booleans.php b/config/set/strict-booleans.php index 921427a90cc..b5be5a0db30 100644 --- a/config/set/strict-booleans.php +++ b/config/set/strict-booleans.php @@ -3,18 +3,8 @@ declare(strict_types=1); use Rector\Config\RectorConfig; -use Rector\Strict\Rector\BooleanNot\BooleanInBooleanNotRuleFixerRector; use Rector\Strict\Rector\Empty_\DisallowedEmptyRuleFixerRector; -use Rector\Strict\Rector\If_\BooleanInIfConditionRuleFixerRector; -use Rector\Strict\Rector\Ternary\BooleanInTernaryOperatorRuleFixerRector; -use Rector\Strict\Rector\Ternary\DisallowedShortTernaryRuleFixerRector; return static function (RectorConfig $rectorConfig): void { - $rectorConfig->rules([ - BooleanInBooleanNotRuleFixerRector::class, - DisallowedEmptyRuleFixerRector::class, - BooleanInIfConditionRuleFixerRector::class, - BooleanInTernaryOperatorRuleFixerRector::class, - DisallowedShortTernaryRuleFixerRector::class, - ]); + $rectorConfig->rules([DisallowedEmptyRuleFixerRector::class]); }; diff --git a/rules-tests/Strict/Rector/BooleanNot/BooleanInBooleanNotRuleFixerRector/BooleanInBooleanNotRuleFixerRectorTest.php b/rules-tests/Strict/Rector/BooleanNot/BooleanInBooleanNotRuleFixerRector/BooleanInBooleanNotRuleFixerRectorTest.php deleted file mode 100644 index 19c8bbde101..00000000000 --- a/rules-tests/Strict/Rector/BooleanNot/BooleanInBooleanNotRuleFixerRector/BooleanInBooleanNotRuleFixerRectorTest.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/Strict/Rector/BooleanNot/BooleanInBooleanNotRuleFixerRector/Fixture/negated_integer.php.inc b/rules-tests/Strict/Rector/BooleanNot/BooleanInBooleanNotRuleFixerRector/Fixture/negated_integer.php.inc deleted file mode 100644 index bc318b39876..00000000000 --- a/rules-tests/Strict/Rector/BooleanNot/BooleanInBooleanNotRuleFixerRector/Fixture/negated_integer.php.inc +++ /dev/null @@ -1,43 +0,0 @@ -age) { - return 'age'; - } - - return 'no age'; - } -} - -?> ------ -age === 0) { - return 'age'; - } - - return 'no age'; - } -} - -?> diff --git a/rules-tests/Strict/Rector/BooleanNot/BooleanInBooleanNotRuleFixerRector/Fixture/negated_preg_match.php.inc b/rules-tests/Strict/Rector/BooleanNot/BooleanInBooleanNotRuleFixerRector/Fixture/negated_preg_match.php.inc deleted file mode 100644 index ddd28fc16da..00000000000 --- a/rules-tests/Strict/Rector/BooleanNot/BooleanInBooleanNotRuleFixerRector/Fixture/negated_preg_match.php.inc +++ /dev/null @@ -1,37 +0,0 @@ - ------ - diff --git a/rules-tests/Strict/Rector/BooleanNot/BooleanInBooleanNotRuleFixerRector/Fixture/negated_string.php.inc b/rules-tests/Strict/Rector/BooleanNot/BooleanInBooleanNotRuleFixerRector/Fixture/negated_string.php.inc deleted file mode 100644 index 952e9d2f4b6..00000000000 --- a/rules-tests/Strict/Rector/BooleanNot/BooleanInBooleanNotRuleFixerRector/Fixture/negated_string.php.inc +++ /dev/null @@ -1,43 +0,0 @@ -name) { - return 'name'; - } - - return 'no name'; - } -} - -?> ------ -name === '' || $this->name === '0') { - return 'name'; - } - - return 'no name'; - } -} - -?> diff --git a/rules-tests/Strict/Rector/BooleanNot/BooleanInBooleanNotRuleFixerRector/Fixture/skip_docblock.php.inc b/rules-tests/Strict/Rector/BooleanNot/BooleanInBooleanNotRuleFixerRector/Fixture/skip_docblock.php.inc deleted file mode 100644 index c30376f6067..00000000000 --- a/rules-tests/Strict/Rector/BooleanNot/BooleanInBooleanNotRuleFixerRector/Fixture/skip_docblock.php.inc +++ /dev/null @@ -1,20 +0,0 @@ -getClass(), PostRectorInterface::class, true); - } -} diff --git a/rules-tests/Strict/Rector/BooleanNot/BooleanInBooleanNotRuleFixerRector/Fixture/string_null_and_false.php.inc b/rules-tests/Strict/Rector/BooleanNot/BooleanInBooleanNotRuleFixerRector/Fixture/string_null_and_false.php.inc deleted file mode 100644 index aab23d712d7..00000000000 --- a/rules-tests/Strict/Rector/BooleanNot/BooleanInBooleanNotRuleFixerRector/Fixture/string_null_and_false.php.inc +++ /dev/null @@ -1,39 +0,0 @@ - ------ - diff --git a/rules-tests/Strict/Rector/BooleanNot/BooleanInBooleanNotRuleFixerRector/Fixture/string_union_integer.php.inc b/rules-tests/Strict/Rector/BooleanNot/BooleanInBooleanNotRuleFixerRector/Fixture/string_union_integer.php.inc deleted file mode 100644 index 6d7db36b1e5..00000000000 --- a/rules-tests/Strict/Rector/BooleanNot/BooleanInBooleanNotRuleFixerRector/Fixture/string_union_integer.php.inc +++ /dev/null @@ -1,39 +0,0 @@ - ------ - diff --git a/rules-tests/Strict/Rector/BooleanNot/BooleanInBooleanNotRuleFixerRector/Fixture/union_null_boolean.php.inc b/rules-tests/Strict/Rector/BooleanNot/BooleanInBooleanNotRuleFixerRector/Fixture/union_null_boolean.php.inc deleted file mode 100644 index e4c8fa71cd7..00000000000 --- a/rules-tests/Strict/Rector/BooleanNot/BooleanInBooleanNotRuleFixerRector/Fixture/union_null_boolean.php.inc +++ /dev/null @@ -1,39 +0,0 @@ - ------ - diff --git a/rules-tests/Strict/Rector/BooleanNot/BooleanInBooleanNotRuleFixerRector/Fixture/union_with_null.php.inc b/rules-tests/Strict/Rector/BooleanNot/BooleanInBooleanNotRuleFixerRector/Fixture/union_with_null.php.inc deleted file mode 100644 index 64a4ed221fe..00000000000 --- a/rules-tests/Strict/Rector/BooleanNot/BooleanInBooleanNotRuleFixerRector/Fixture/union_with_null.php.inc +++ /dev/null @@ -1,43 +0,0 @@ -value) { - return 'empty'; - } - - return 'set'; - } -} - -?> ------ -value === null || $this->value === '' || $this->value === '0') { - return 'empty'; - } - - return 'set'; - } -} - -?> diff --git a/rules-tests/Strict/Rector/BooleanNot/BooleanInBooleanNotRuleFixerRector/Fixture/union_with_null_from_param.php.inc b/rules-tests/Strict/Rector/BooleanNot/BooleanInBooleanNotRuleFixerRector/Fixture/union_with_null_from_param.php.inc deleted file mode 100644 index 8fa49eef456..00000000000 --- a/rules-tests/Strict/Rector/BooleanNot/BooleanInBooleanNotRuleFixerRector/Fixture/union_with_null_from_param.php.inc +++ /dev/null @@ -1,39 +0,0 @@ - ------ - diff --git a/rules-tests/Strict/Rector/BooleanNot/BooleanInBooleanNotRuleFixerRector/FixtureTreatAsNonEmpty/string_null_and_false.php.inc b/rules-tests/Strict/Rector/BooleanNot/BooleanInBooleanNotRuleFixerRector/FixtureTreatAsNonEmpty/string_null_and_false.php.inc deleted file mode 100644 index e329cb6879f..00000000000 --- a/rules-tests/Strict/Rector/BooleanNot/BooleanInBooleanNotRuleFixerRector/FixtureTreatAsNonEmpty/string_null_and_false.php.inc +++ /dev/null @@ -1,39 +0,0 @@ - ------ - diff --git a/rules-tests/Strict/Rector/BooleanNot/BooleanInBooleanNotRuleFixerRector/FixtureTreatAsNonEmpty/union_with_null.php.inc b/rules-tests/Strict/Rector/BooleanNot/BooleanInBooleanNotRuleFixerRector/FixtureTreatAsNonEmpty/union_with_null.php.inc deleted file mode 100644 index 3b2bace039b..00000000000 --- a/rules-tests/Strict/Rector/BooleanNot/BooleanInBooleanNotRuleFixerRector/FixtureTreatAsNonEmpty/union_with_null.php.inc +++ /dev/null @@ -1,43 +0,0 @@ -value) { - return 'empty'; - } - - return 'set'; - } -} - -?> ------ -value === null) { - return 'empty'; - } - - return 'set'; - } -} - -?> diff --git a/rules-tests/Strict/Rector/BooleanNot/BooleanInBooleanNotRuleFixerRector/FixtureTreatAsNonEmpty/union_with_null_from_param.php.inc b/rules-tests/Strict/Rector/BooleanNot/BooleanInBooleanNotRuleFixerRector/FixtureTreatAsNonEmpty/union_with_null_from_param.php.inc deleted file mode 100644 index 0f279dcaa62..00000000000 --- a/rules-tests/Strict/Rector/BooleanNot/BooleanInBooleanNotRuleFixerRector/FixtureTreatAsNonEmpty/union_with_null_from_param.php.inc +++ /dev/null @@ -1,39 +0,0 @@ - ------ - diff --git a/rules-tests/Strict/Rector/BooleanNot/BooleanInBooleanNotRuleFixerRector/TreatAsNonEmptyRectorTest.php b/rules-tests/Strict/Rector/BooleanNot/BooleanInBooleanNotRuleFixerRector/TreatAsNonEmptyRectorTest.php deleted file mode 100644 index 22c6927b590..00000000000 --- a/rules-tests/Strict/Rector/BooleanNot/BooleanInBooleanNotRuleFixerRector/TreatAsNonEmptyRectorTest.php +++ /dev/null @@ -1,28 +0,0 @@ -doTestFile($filePath); - } - - public static function provideData(): Iterator - { - return self::yieldFilesFromDirectory(__DIR__ . '/FixtureTreatAsNonEmpty'); - } - - public function provideConfigFilePath(): string - { - return __DIR__ . '/config/treat_as_non_empty.php'; - } -} diff --git a/rules-tests/Strict/Rector/BooleanNot/BooleanInBooleanNotRuleFixerRector/config/configured_rule.php b/rules-tests/Strict/Rector/BooleanNot/BooleanInBooleanNotRuleFixerRector/config/configured_rule.php deleted file mode 100644 index e9b7bebe3af..00000000000 --- a/rules-tests/Strict/Rector/BooleanNot/BooleanInBooleanNotRuleFixerRector/config/configured_rule.php +++ /dev/null @@ -1,9 +0,0 @@ -withRules([BooleanInBooleanNotRuleFixerRector::class]); diff --git a/rules-tests/Strict/Rector/BooleanNot/BooleanInBooleanNotRuleFixerRector/config/treat_as_non_empty.php b/rules-tests/Strict/Rector/BooleanNot/BooleanInBooleanNotRuleFixerRector/config/treat_as_non_empty.php deleted file mode 100644 index 7bab2399ad4..00000000000 --- a/rules-tests/Strict/Rector/BooleanNot/BooleanInBooleanNotRuleFixerRector/config/treat_as_non_empty.php +++ /dev/null @@ -1,13 +0,0 @@ -ruleWithConfiguration(BooleanInBooleanNotRuleFixerRector::class, [ - BooleanInBooleanNotRuleFixerRector::TREAT_AS_NON_EMPTY => true, - ]); -}; diff --git a/rules-tests/Strict/Rector/If_/BooleanInIfConditionRuleFixerRector/BooleanInIfConditionRuleFixerRectorTest.php b/rules-tests/Strict/Rector/If_/BooleanInIfConditionRuleFixerRector/BooleanInIfConditionRuleFixerRectorTest.php deleted file mode 100644 index e63fed08cfe..00000000000 --- a/rules-tests/Strict/Rector/If_/BooleanInIfConditionRuleFixerRector/BooleanInIfConditionRuleFixerRectorTest.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/Strict/Rector/If_/BooleanInIfConditionRuleFixerRector/Fixture/array_from_filter.php.inc b/rules-tests/Strict/Rector/If_/BooleanInIfConditionRuleFixerRector/Fixture/array_from_filter.php.inc deleted file mode 100644 index b46e3a49e9d..00000000000 --- a/rules-tests/Strict/Rector/If_/BooleanInIfConditionRuleFixerRector/Fixture/array_from_filter.php.inc +++ /dev/null @@ -1,39 +0,0 @@ - ------ - diff --git a/rules-tests/Strict/Rector/If_/BooleanInIfConditionRuleFixerRector/Fixture/elseif_negated_string.php.inc b/rules-tests/Strict/Rector/If_/BooleanInIfConditionRuleFixerRector/Fixture/elseif_negated_string.php.inc deleted file mode 100644 index f8f3b77cb26..00000000000 --- a/rules-tests/Strict/Rector/If_/BooleanInIfConditionRuleFixerRector/Fixture/elseif_negated_string.php.inc +++ /dev/null @@ -1,47 +0,0 @@ -name) { - return 'name'; - } - - return 'no name'; - } -} - -?> ------ -name !== '' && $this->name !== '0') { - return 'name'; - } - - return 'no name'; - } -} - -?> diff --git a/rules-tests/Strict/Rector/If_/BooleanInIfConditionRuleFixerRector/Fixture/in_assign.php.inc b/rules-tests/Strict/Rector/If_/BooleanInIfConditionRuleFixerRector/Fixture/in_assign.php.inc deleted file mode 100644 index b158a9fc579..00000000000 --- a/rules-tests/Strict/Rector/If_/BooleanInIfConditionRuleFixerRector/Fixture/in_assign.php.inc +++ /dev/null @@ -1,47 +0,0 @@ -getList()) { - echo $items[0]; - } - } -} - -?> ------ -getList()) !== []) { - echo $items[0]; - } - } -} - -?> diff --git a/rules-tests/Strict/Rector/If_/BooleanInIfConditionRuleFixerRector/Fixture/integer_union_string.php.inc b/rules-tests/Strict/Rector/If_/BooleanInIfConditionRuleFixerRector/Fixture/integer_union_string.php.inc deleted file mode 100644 index 3d0eb4a014b..00000000000 --- a/rules-tests/Strict/Rector/If_/BooleanInIfConditionRuleFixerRector/Fixture/integer_union_string.php.inc +++ /dev/null @@ -1,39 +0,0 @@ - ------ - diff --git a/rules-tests/Strict/Rector/If_/BooleanInIfConditionRuleFixerRector/Fixture/negated_string.php.inc b/rules-tests/Strict/Rector/If_/BooleanInIfConditionRuleFixerRector/Fixture/negated_string.php.inc deleted file mode 100644 index e8f028b62be..00000000000 --- a/rules-tests/Strict/Rector/If_/BooleanInIfConditionRuleFixerRector/Fixture/negated_string.php.inc +++ /dev/null @@ -1,43 +0,0 @@ -name) { - return 'name'; - } - - return 'no name'; - } -} - -?> ------ -name !== '' && $this->name !== '0') { - return 'name'; - } - - return 'no name'; - } -} - -?> diff --git a/rules-tests/Strict/Rector/If_/BooleanInIfConditionRuleFixerRector/Fixture/nullable_bool.php.inc b/rules-tests/Strict/Rector/If_/BooleanInIfConditionRuleFixerRector/Fixture/nullable_bool.php.inc deleted file mode 100644 index bb9e892d539..00000000000 --- a/rules-tests/Strict/Rector/If_/BooleanInIfConditionRuleFixerRector/Fixture/nullable_bool.php.inc +++ /dev/null @@ -1,39 +0,0 @@ - ------ - diff --git a/rules-tests/Strict/Rector/If_/BooleanInIfConditionRuleFixerRector/Fixture/nullable_object.php.inc b/rules-tests/Strict/Rector/If_/BooleanInIfConditionRuleFixerRector/Fixture/nullable_object.php.inc deleted file mode 100644 index b2206d945d7..00000000000 --- a/rules-tests/Strict/Rector/If_/BooleanInIfConditionRuleFixerRector/Fixture/nullable_object.php.inc +++ /dev/null @@ -1,39 +0,0 @@ - ------ - diff --git a/rules-tests/Strict/Rector/If_/BooleanInIfConditionRuleFixerRector/Fixture/skip_from_return_docblock.php.inc b/rules-tests/Strict/Rector/If_/BooleanInIfConditionRuleFixerRector/Fixture/skip_from_return_docblock.php.inc deleted file mode 100644 index b7bc46820cc..00000000000 --- a/rules-tests/Strict/Rector/If_/BooleanInIfConditionRuleFixerRector/Fixture/skip_from_return_docblock.php.inc +++ /dev/null @@ -1,24 +0,0 @@ -getItems()) { - return true; - } - - return false; - } -} diff --git a/rules-tests/Strict/Rector/If_/BooleanInIfConditionRuleFixerRector/Fixture/skip_result_object.php.inc b/rules-tests/Strict/Rector/If_/BooleanInIfConditionRuleFixerRector/Fixture/skip_result_object.php.inc deleted file mode 100644 index 46d7f045267..00000000000 --- a/rules-tests/Strict/Rector/If_/BooleanInIfConditionRuleFixerRector/Fixture/skip_result_object.php.inc +++ /dev/null @@ -1,41 +0,0 @@ -type === self::SELECT) { - return new ForwardCompatibilityResult(); - } - - return 1; - } -} - -class SkipResultObject -{ - public function insert(): bool { - $queryBuilder = new QueryBuilder(); - if ($queryBuilder->execute()) { - return false; - } - - throw new \RuntimeException('...'); - } -} diff --git a/rules-tests/Strict/Rector/If_/BooleanInIfConditionRuleFixerRector/Fixture/skip_stripos.php.inc b/rules-tests/Strict/Rector/If_/BooleanInIfConditionRuleFixerRector/Fixture/skip_stripos.php.inc deleted file mode 100644 index 9ddd097b53c..00000000000 --- a/rules-tests/Strict/Rector/If_/BooleanInIfConditionRuleFixerRector/Fixture/skip_stripos.php.inc +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/rules-tests/Strict/Rector/If_/BooleanInIfConditionRuleFixerRector/config/configured_rule.php b/rules-tests/Strict/Rector/If_/BooleanInIfConditionRuleFixerRector/config/configured_rule.php deleted file mode 100644 index b402252de42..00000000000 --- a/rules-tests/Strict/Rector/If_/BooleanInIfConditionRuleFixerRector/config/configured_rule.php +++ /dev/null @@ -1,9 +0,0 @@ -withRules([BooleanInIfConditionRuleFixerRector::class]); diff --git a/rules-tests/Strict/Rector/Ternary/BooleanInTernaryOperatorRuleFixerRector/BooleanInTernaryOperatorRuleFixerRectorTest.php b/rules-tests/Strict/Rector/Ternary/BooleanInTernaryOperatorRuleFixerRector/BooleanInTernaryOperatorRuleFixerRectorTest.php deleted file mode 100644 index 672258da9b7..00000000000 --- a/rules-tests/Strict/Rector/Ternary/BooleanInTernaryOperatorRuleFixerRector/BooleanInTernaryOperatorRuleFixerRectorTest.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/Strict/Rector/Ternary/BooleanInTernaryOperatorRuleFixerRector/Fixture/array_compare.php.inc b/rules-tests/Strict/Rector/Ternary/BooleanInTernaryOperatorRuleFixerRector/Fixture/array_compare.php.inc deleted file mode 100644 index 5844d9d0cd6..00000000000 --- a/rules-tests/Strict/Rector/Ternary/BooleanInTernaryOperatorRuleFixerRector/Fixture/array_compare.php.inc +++ /dev/null @@ -1,31 +0,0 @@ - ------ - diff --git a/rules-tests/Strict/Rector/Ternary/BooleanInTernaryOperatorRuleFixerRector/Fixture/nullable_string.php.inc b/rules-tests/Strict/Rector/Ternary/BooleanInTernaryOperatorRuleFixerRector/Fixture/nullable_string.php.inc deleted file mode 100644 index 482d52d578b..00000000000 --- a/rules-tests/Strict/Rector/Ternary/BooleanInTernaryOperatorRuleFixerRector/Fixture/nullable_string.php.inc +++ /dev/null @@ -1,31 +0,0 @@ - ------ - diff --git a/rules-tests/Strict/Rector/Ternary/BooleanInTernaryOperatorRuleFixerRector/Fixture/skip_docblock.php.inc b/rules-tests/Strict/Rector/Ternary/BooleanInTernaryOperatorRuleFixerRector/Fixture/skip_docblock.php.inc deleted file mode 100644 index f663fb9bcb7..00000000000 --- a/rules-tests/Strict/Rector/Ternary/BooleanInTernaryOperatorRuleFixerRector/Fixture/skip_docblock.php.inc +++ /dev/null @@ -1,16 +0,0 @@ - ------ - diff --git a/rules-tests/Strict/Rector/Ternary/BooleanInTernaryOperatorRuleFixerRector/Fixture/strlen_number.php.inc b/rules-tests/Strict/Rector/Ternary/BooleanInTernaryOperatorRuleFixerRector/Fixture/strlen_number.php.inc deleted file mode 100644 index 5bcde5fddb6..00000000000 --- a/rules-tests/Strict/Rector/Ternary/BooleanInTernaryOperatorRuleFixerRector/Fixture/strlen_number.php.inc +++ /dev/null @@ -1,31 +0,0 @@ - ------ - diff --git a/rules-tests/Strict/Rector/Ternary/BooleanInTernaryOperatorRuleFixerRector/config/configured_rule.php b/rules-tests/Strict/Rector/Ternary/BooleanInTernaryOperatorRuleFixerRector/config/configured_rule.php deleted file mode 100644 index 7dc283ae119..00000000000 --- a/rules-tests/Strict/Rector/Ternary/BooleanInTernaryOperatorRuleFixerRector/config/configured_rule.php +++ /dev/null @@ -1,9 +0,0 @@ -withRules([BooleanInTernaryOperatorRuleFixerRector::class]); diff --git a/rules-tests/Strict/Rector/Ternary/DisallowedShortTernaryRuleFixerRector/DisallowedShortTernaryRuleFixerRectorTest.php b/rules-tests/Strict/Rector/Ternary/DisallowedShortTernaryRuleFixerRector/DisallowedShortTernaryRuleFixerRectorTest.php deleted file mode 100644 index 7a898d6e8c2..00000000000 --- a/rules-tests/Strict/Rector/Ternary/DisallowedShortTernaryRuleFixerRector/DisallowedShortTernaryRuleFixerRectorTest.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/Strict/Rector/Ternary/DisallowedShortTernaryRuleFixerRector/Fixture/reset_trait.php.inc b/rules-tests/Strict/Rector/Ternary/DisallowedShortTernaryRuleFixerRector/Fixture/reset_trait.php.inc deleted file mode 100644 index d1a84abe8e8..00000000000 --- a/rules-tests/Strict/Rector/Ternary/DisallowedShortTernaryRuleFixerRector/Fixture/reset_trait.php.inc +++ /dev/null @@ -1,31 +0,0 @@ - ------ - diff --git a/rules-tests/Strict/Rector/Ternary/DisallowedShortTernaryRuleFixerRector/Fixture/short_ternary_array.php.inc b/rules-tests/Strict/Rector/Ternary/DisallowedShortTernaryRuleFixerRector/Fixture/short_ternary_array.php.inc deleted file mode 100644 index 2f41b8929bf..00000000000 --- a/rules-tests/Strict/Rector/Ternary/DisallowedShortTernaryRuleFixerRector/Fixture/short_ternary_array.php.inc +++ /dev/null @@ -1,31 +0,0 @@ - ------ - diff --git a/rules-tests/Strict/Rector/Ternary/DisallowedShortTernaryRuleFixerRector/Fixture/short_ternary_string.php.inc b/rules-tests/Strict/Rector/Ternary/DisallowedShortTernaryRuleFixerRector/Fixture/short_ternary_string.php.inc deleted file mode 100644 index 9570675964e..00000000000 --- a/rules-tests/Strict/Rector/Ternary/DisallowedShortTernaryRuleFixerRector/Fixture/short_ternary_string.php.inc +++ /dev/null @@ -1,31 +0,0 @@ - ------ - diff --git a/rules-tests/Strict/Rector/Ternary/DisallowedShortTernaryRuleFixerRector/Fixture/skip_docblock.php.inc b/rules-tests/Strict/Rector/Ternary/DisallowedShortTernaryRuleFixerRector/Fixture/skip_docblock.php.inc deleted file mode 100644 index 3bd7c6889b8..00000000000 --- a/rules-tests/Strict/Rector/Ternary/DisallowedShortTernaryRuleFixerRector/Fixture/skip_docblock.php.inc +++ /dev/null @@ -1,16 +0,0 @@ -withRules([DisallowedShortTernaryRuleFixerRector::class]); diff --git a/rules/Strict/Rector/AbstractFalsyScalarRuleFixerRector.php b/rules/Strict/Rector/AbstractFalsyScalarRuleFixerRector.php index 742da71d056..ac4f08572c1 100644 --- a/rules/Strict/Rector/AbstractFalsyScalarRuleFixerRector.php +++ b/rules/Strict/Rector/AbstractFalsyScalarRuleFixerRector.php @@ -9,8 +9,6 @@ use Webmozart\Assert\Assert; /** - * @see \Rector\Tests\Strict\Rector\BooleanNot\BooleanInBooleanNotRuleFixerRector\BooleanInBooleanNotRuleFixerRectorTest - * * @internal */ abstract class AbstractFalsyScalarRuleFixerRector extends AbstractRector implements ConfigurableRectorInterface diff --git a/rules/Strict/Rector/BooleanNot/BooleanInBooleanNotRuleFixerRector.php b/rules/Strict/Rector/BooleanNot/BooleanInBooleanNotRuleFixerRector.php index cd80d0fc4c9..eac390488fc 100644 --- a/rules/Strict/Rector/BooleanNot/BooleanInBooleanNotRuleFixerRector.php +++ b/rules/Strict/Rector/BooleanNot/BooleanInBooleanNotRuleFixerRector.php @@ -7,24 +7,18 @@ use PhpParser\Node; use PhpParser\Node\Expr; use PhpParser\Node\Expr\BooleanNot; -use Rector\PHPStan\ScopeFetcher; -use Rector\Strict\NodeFactory\ExactCompareFactory; -use Rector\Strict\Rector\AbstractFalsyScalarRuleFixerRector; +use Rector\Configuration\Deprecation\Contract\DeprecatedInterface; +use Rector\Exception\ShouldNotHappenException; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** - * Fixer Rector for PHPStan rule: - * https://github.com/phpstan/phpstan-strict-rules/blob/0705fefc7c9168529fd130e341428f5f10f4f01d/src/Rules/BooleansInConditions/BooleanInBooleanNotRule.php - * - * @see \Rector\Tests\Strict\Rector\BooleanNot\BooleanInBooleanNotRuleFixerRector\BooleanInBooleanNotRuleFixerRectorTest + * @deprecated as risky and requires manual checking */ -final class BooleanInBooleanNotRuleFixerRector extends AbstractFalsyScalarRuleFixerRector +final class BooleanInBooleanNotRuleFixerRector extends AbstractRector implements DeprecatedInterface { - public function __construct( - private readonly ExactCompareFactory $exactCompareFactory - ) { - } + public const TREAT_AS_NON_EMPTY = 'treat_as_non_empty'; public function getRuleDefinition(): RuleDefinition { @@ -82,13 +76,6 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Expr { - $scope = ScopeFetcher::fetch($node); - - $exprType = $scope->getNativeType($node->expr); - if ($exprType->isBoolean()->yes()) { - return null; - } - - return $this->exactCompareFactory->createIdenticalFalsyCompare($exprType, $node->expr, $this->treatAsNonEmpty); + throw new ShouldNotHappenException('This rule is deprecated as risky and not practical'); } } diff --git a/rules/Strict/Rector/If_/BooleanInIfConditionRuleFixerRector.php b/rules/Strict/Rector/If_/BooleanInIfConditionRuleFixerRector.php index 47feb2694f4..adc1e17afbf 100644 --- a/rules/Strict/Rector/If_/BooleanInIfConditionRuleFixerRector.php +++ b/rules/Strict/Rector/If_/BooleanInIfConditionRuleFixerRector.php @@ -5,27 +5,19 @@ namespace Rector\Strict\Rector\If_; use PhpParser\Node; -use PhpParser\Node\Expr; use PhpParser\Node\Stmt\If_; -use Rector\PHPStan\ScopeFetcher; -use Rector\Strict\NodeFactory\ExactCompareFactory; -use Rector\Strict\Rector\AbstractFalsyScalarRuleFixerRector; +use Rector\Configuration\Deprecation\Contract\DeprecatedInterface; +use Rector\Exception\ShouldNotHappenException; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** - * Fixer Rector for PHPStan rules: - * https://github.com/phpstan/phpstan-strict-rules/blob/master/src/Rules/BooleansInConditions/BooleanInIfConditionRule.php - * https://github.com/phpstan/phpstan-strict-rules/blob/master/src/Rules/BooleansInConditions/BooleanInElseIfConditionRule.php - * - * @see \Rector\Tests\Strict\Rector\If_\BooleanInIfConditionRuleFixerRector\BooleanInIfConditionRuleFixerRectorTest + * @deprecated this rule is risky and requires manual checking */ -final class BooleanInIfConditionRuleFixerRector extends AbstractFalsyScalarRuleFixerRector +final class BooleanInIfConditionRuleFixerRector extends AbstractRector implements DeprecatedInterface { - public function __construct( - private readonly ExactCompareFactory $exactCompareFactory - ) { - } + public const TREAT_AS_NON_EMPTY = 'treat_as_non_empty'; public function getRuleDefinition(): RuleDefinition { @@ -83,45 +75,8 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?If_ { - $hasChanged = false; - - $scope = ScopeFetcher::fetch($node); - - // 1. if - $ifCondExprType = $scope->getNativeType($node->cond); - $notIdentical = $this->exactCompareFactory->createNotIdenticalFalsyCompare( - $ifCondExprType, - $node->cond, - $this->treatAsNonEmpty + throw new ShouldNotHappenException( + 'This rule is deprecated and will be removed as risky and requires manual checking' ); - if ($notIdentical !== null) { - $node->cond = $notIdentical; - - $hasChanged = true; - } - - // 2. elseifs - foreach ($node->elseifs as $elseif) { - $elseifCondExprType = $scope->getNativeType($elseif->cond); - $notIdentical = $this->exactCompareFactory->createNotIdenticalFalsyCompare( - $elseifCondExprType, - $elseif->cond, - $this->treatAsNonEmpty - ); - - if (! $notIdentical instanceof Expr) { - continue; - } - - $elseif->cond = $notIdentical; - - $hasChanged = true; - } - - if ($hasChanged) { - return $node; - } - - return null; } } diff --git a/rules/Strict/Rector/Ternary/BooleanInTernaryOperatorRuleFixerRector.php b/rules/Strict/Rector/Ternary/BooleanInTernaryOperatorRuleFixerRector.php index e647ad252c4..e72274af5f2 100644 --- a/rules/Strict/Rector/Ternary/BooleanInTernaryOperatorRuleFixerRector.php +++ b/rules/Strict/Rector/Ternary/BooleanInTernaryOperatorRuleFixerRector.php @@ -5,26 +5,19 @@ namespace Rector\Strict\Rector\Ternary; use PhpParser\Node; -use PhpParser\Node\Expr; use PhpParser\Node\Expr\Ternary; -use Rector\PHPStan\ScopeFetcher; -use Rector\Strict\NodeFactory\ExactCompareFactory; -use Rector\Strict\Rector\AbstractFalsyScalarRuleFixerRector; +use Rector\Configuration\Deprecation\Contract\DeprecatedInterface; +use Rector\Exception\ShouldNotHappenException; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** - * Fixer Rector for PHPStan rule: - * https://github.com/phpstan/phpstan-strict-rules/blob/master/src/Rules/BooleansInConditions/BooleanInTernaryOperatorRule.php - * - * @see \Rector\Tests\Strict\Rector\Ternary\BooleanInTernaryOperatorRuleFixerRector\BooleanInTernaryOperatorRuleFixerRectorTest + * @deprecated as risky and requires manual checking */ -final class BooleanInTernaryOperatorRuleFixerRector extends AbstractFalsyScalarRuleFixerRector +final class BooleanInTernaryOperatorRuleFixerRector extends AbstractRector implements DeprecatedInterface { - public function __construct( - private readonly ExactCompareFactory $exactCompareFactory - ) { - } + public const TREAT_AS_NON_EMPTY = 'treat_as_non_empty'; public function getRuleDefinition(): RuleDefinition { @@ -74,25 +67,6 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Ternary { - // skip short ternary - if (! $node->if instanceof Expr) { - return null; - } - - $scope = ScopeFetcher::fetch($node); - $exprType = $scope->getNativeType($node->cond); - - $expr = $this->exactCompareFactory->createNotIdenticalFalsyCompare( - $exprType, - $node->cond, - $this->treatAsNonEmpty - ); - if (! $expr instanceof Expr) { - return null; - } - - $node->cond = $expr; - - return $node; + throw new ShouldNotHappenException('This rule is deprecated as risky and not practical'); } } diff --git a/rules/Strict/Rector/Ternary/DisallowedShortTernaryRuleFixerRector.php b/rules/Strict/Rector/Ternary/DisallowedShortTernaryRuleFixerRector.php index 997c20f7aae..df2a9bd2940 100644 --- a/rules/Strict/Rector/Ternary/DisallowedShortTernaryRuleFixerRector.php +++ b/rules/Strict/Rector/Ternary/DisallowedShortTernaryRuleFixerRector.php @@ -5,13 +5,10 @@ namespace Rector\Strict\Rector\Ternary; use PhpParser\Node; -use PhpParser\Node\Expr; -use PhpParser\Node\Expr\FuncCall; use PhpParser\Node\Expr\Ternary; -use PHPStan\Analyser\Scope; -use Rector\PHPStan\ScopeFetcher; -use Rector\Strict\NodeFactory\ExactCompareFactory; -use Rector\Strict\Rector\AbstractFalsyScalarRuleFixerRector; +use Rector\Configuration\Deprecation\Contract\DeprecatedInterface; +use Rector\Exception\ShouldNotHappenException; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; @@ -19,16 +16,11 @@ * Fixer Rector for PHPStan rule: * https://github.com/phpstan/phpstan-strict-rules/blob/master/src/Rules/DisallowedConstructs/DisallowedShortTernaryRule.php * - * @see \Rector\Tests\Strict\Rector\Ternary\DisallowedShortTernaryRuleFixerRector\DisallowedShortTernaryRuleFixerRectorTest + * @deprecated as risky and not practical */ -final class DisallowedShortTernaryRuleFixerRector extends AbstractFalsyScalarRuleFixerRector +final class DisallowedShortTernaryRuleFixerRector extends AbstractRector implements DeprecatedInterface { - private bool $hasChanged = false; - - public function __construct( - private readonly ExactCompareFactory $exactCompareFactory, - ) { - } + public const TREAT_AS_NON_EMPTY = 'treat_as_non_empty'; public function getRuleDefinition(): RuleDefinition { @@ -78,65 +70,6 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Ternary { - $this->hasChanged = false; - - // skip non-short ternary - if ($node->if instanceof Expr) { - return null; - } - - $scope = ScopeFetcher::fetch($node); - - // special case for reset() function - if ($node->cond instanceof FuncCall && $this->isName($node->cond, 'reset')) { - $this->refactorResetFuncCall($node, $node->cond, $scope); - - if (! $this->hasChanged) { - return null; - } - - return $node; - } - - $exprType = $scope->getNativeType($node->cond); - $compareExpr = $this->exactCompareFactory->createNotIdenticalFalsyCompare( - $exprType, - $node->cond, - $this->treatAsNonEmpty - ); - if (! $compareExpr instanceof Expr) { - return null; - } - - $node->if = $node->cond; - $node->cond = $compareExpr; - - return $node; - } - - private function refactorResetFuncCall(Ternary $ternary, FuncCall $resetFuncCall, Scope $scope): void - { - $ternary->if = $ternary->cond; - - if ($resetFuncCall->isFirstClassCallable()) { - return; - } - - $firstArgValue = $resetFuncCall->getArgs()[0] - ->value; - $firstArgType = $scope->getNativeType($firstArgValue); - - $falsyCompareExpr = $this->exactCompareFactory->createNotIdenticalFalsyCompare( - $firstArgType, - $firstArgValue, - $this->treatAsNonEmpty - ); - - if (! $falsyCompareExpr instanceof Expr) { - return; - } - - $ternary->cond = $falsyCompareExpr; - $this->hasChanged = true; + throw new ShouldNotHappenException('This rule is deprecated as risky and not practical'); } } diff --git a/src/Configuration/RectorConfigBuilder.php b/src/Configuration/RectorConfigBuilder.php index bcd3d4cde72..5a8daf6bef7 100644 --- a/src/Configuration/RectorConfigBuilder.php +++ b/src/Configuration/RectorConfigBuilder.php @@ -760,6 +760,7 @@ public function withPreparedSets( bool $naming = false, bool $instanceOf = false, bool $earlyReturn = false, + /** @deprecated */ bool $strictBooleans = false, bool $carbon = false, bool $rectorPreset = false, @@ -780,7 +781,6 @@ public function withPreparedSets( SetList::NAMING => $naming, SetList::INSTANCEOF => $instanceOf, SetList::EARLY_RETURN => $earlyReturn, - SetList::STRICT_BOOLEANS => $strictBooleans, SetList::CARBON => $carbon, SetList::RECTOR_PRESET => $rectorPreset, PHPUnitSetList::PHPUNIT_CODE_QUALITY => $phpunitCodeQuality, diff --git a/src/Set/ValueObject/SetList.php b/src/Set/ValueObject/SetList.php index d7e17163802..5dc2a7ce781 100644 --- a/src/Set/ValueObject/SetList.php +++ b/src/Set/ValueObject/SetList.php @@ -31,6 +31,7 @@ final class SetList public const DEAD_CODE = __DIR__ . '/../../../config/set/dead-code.php'; /** + * @deprecated As too strict and not practical. Use code quality and coding style sets instead. * @var string */ public const STRICT_BOOLEANS = __DIR__ . '/../../../config/set/strict-booleans.php'; diff --git a/tests/Issues/EmptyBooleanCompare/EmptyBooleanCompareTest.php b/tests/Issues/EmptyBooleanCompare/EmptyBooleanCompareTest.php deleted file mode 100644 index baa78b7932e..00000000000 --- a/tests/Issues/EmptyBooleanCompare/EmptyBooleanCompareTest.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/tests/Issues/EmptyBooleanCompare/Fixture/always_exists_array_dim_fetch_item.php.inc b/tests/Issues/EmptyBooleanCompare/Fixture/always_exists_array_dim_fetch_item.php.inc deleted file mode 100644 index 575df9a0cea..00000000000 --- a/tests/Issues/EmptyBooleanCompare/Fixture/always_exists_array_dim_fetch_item.php.inc +++ /dev/null @@ -1,55 +0,0 @@ - 'foo', - ]; - } else { - $parts = [ - 'host' => '', - ]; - } - - if (!empty($parts['host'])) { - return $parts['host']; - } - - return null; - } -} - -?> ------ - 'foo', - ]; - } else { - $parts = [ - 'host' => '', - ]; - } - - if (isset($parts['host']) && ($parts['host'] !== '' && $parts['host'] !== '0')) { - return $parts['host']; - } - - return null; - } -} - -?> diff --git a/tests/Issues/EmptyBooleanCompare/Fixture/fixture.php.inc b/tests/Issues/EmptyBooleanCompare/Fixture/fixture.php.inc deleted file mode 100644 index c7e385b05cc..00000000000 --- a/tests/Issues/EmptyBooleanCompare/Fixture/fixture.php.inc +++ /dev/null @@ -1,39 +0,0 @@ - ------ - diff --git a/tests/Issues/EmptyBooleanCompare/Fixture/on_array_object.php.inc b/tests/Issues/EmptyBooleanCompare/Fixture/on_array_object.php.inc deleted file mode 100644 index 558cd891c11..00000000000 --- a/tests/Issues/EmptyBooleanCompare/Fixture/on_array_object.php.inc +++ /dev/null @@ -1,39 +0,0 @@ - 'test'], \ArrayObject::ARRAY_AS_PROPS); - - if (!empty($parts['host'])) { - return $parts['host']; - } - - return null; - } -} - -?> ------ - 'test'], \ArrayObject::ARRAY_AS_PROPS); - - if (isset($parts['host']) && ($parts['host'] !== '' && $parts['host'] !== '0')) { - return $parts['host']; - } - - return null; - } -} - -?> diff --git a/tests/Issues/EmptyBooleanCompare/Fixture/skip_array_dim_fetch_from_docblock.php.inc b/tests/Issues/EmptyBooleanCompare/Fixture/skip_array_dim_fetch_from_docblock.php.inc deleted file mode 100644 index 18fe48a3184..00000000000 --- a/tests/Issues/EmptyBooleanCompare/Fixture/skip_array_dim_fetch_from_docblock.php.inc +++ /dev/null @@ -1,18 +0,0 @@ -withRules([BooleanInIfConditionRuleFixerRector::class, DisallowedEmptyRuleFixerRector::class]); diff --git a/tests/Issues/Issue7099/Fixture/fixture.php.inc b/tests/Issues/Issue7099/Fixture/fixture.php.inc deleted file mode 100644 index cdfbad92626..00000000000 --- a/tests/Issues/Issue7099/Fixture/fixture.php.inc +++ /dev/null @@ -1,43 +0,0 @@ - ------ - diff --git a/tests/Issues/Issue7099/RuleCombinationShouldNotRemoveIfEmptyStmtRectorTest.php b/tests/Issues/Issue7099/RuleCombinationShouldNotRemoveIfEmptyStmtRectorTest.php deleted file mode 100644 index 31653735945..00000000000 --- a/tests/Issues/Issue7099/RuleCombinationShouldNotRemoveIfEmptyStmtRectorTest.php +++ /dev/null @@ -1,31 +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/tests/Issues/Issue7099/Source/Document.php b/tests/Issues/Issue7099/Source/Document.php deleted file mode 100644 index 0c4ef0de9ba..00000000000 --- a/tests/Issues/Issue7099/Source/Document.php +++ /dev/null @@ -1,8 +0,0 @@ -rule(RemoveDeadInstanceOfRector::class); - $rectorConfig - ->ruleWithConfiguration(BooleanInTernaryOperatorRuleFixerRector::class, [ - BooleanInTernaryOperatorRuleFixerRector::TREAT_AS_NON_EMPTY => false, - ]); - $rectorConfig - ->ruleWithConfiguration(DisallowedEmptyRuleFixerRector::class, [ - DisallowedEmptyRuleFixerRector::TREAT_AS_NON_EMPTY => false, - ]); -};