diff --git a/build/target-repository/docs/rector_rules_overview.md b/build/target-repository/docs/rector_rules_overview.md index e8c5154fc95..e940876e7f7 100644 --- a/build/target-repository/docs/rector_rules_overview.md +++ b/build/target-repository/docs/rector_rules_overview.md @@ -1,4 +1,4 @@ -# 355 Rules Overview +# 353 Rules Overview
@@ -8,7 +8,7 @@ - [CodeQuality](#codequality) (72) -- [CodingStyle](#codingstyle) (29) +- [CodingStyle](#codingstyle) (28) - [DeadCode](#deadcode) (42) @@ -56,7 +56,7 @@ - [Transform](#transform) (22) -- [TypeDeclaration](#typedeclaration) (42) +- [TypeDeclaration](#typedeclaration) (41) - [Visibility](#visibility) (3) @@ -1623,29 +1623,6 @@ Change `array_merge()` to spread operator
-### BinarySwitchToIfElseRector - -Changes switch with 2 options to if-else - -- class: [`Rector\CodingStyle\Rector\Switch_\BinarySwitchToIfElseRector`](../rules/CodingStyle/Rector/Switch_/BinarySwitchToIfElseRector.php) - -```diff --switch ($foo) { -- case 'my string': -- $result = 'ok'; -- break; -- -- default: -- $result = 'not ok'; -+if ($foo == 'my string') { -+ $result = 'ok'; -+} else { -+ $result = 'not ok'; - } -``` - -
- ### CallUserFuncArrayToVariadicRector Replace `call_user_func_array()` with variadic @@ -7022,30 +6999,6 @@ Add typed property from assigned types
-### TypedPropertyFromStrictConstructorReadonlyClassRector - -Add typed public properties based only on strict constructor types in readonly classes - -- class: [`Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictConstructorReadonlyClassRector`](../rules/TypeDeclaration/Rector/Property/TypedPropertyFromStrictConstructorReadonlyClassRector.php) - -```diff - /** - * @immutable - */ - class SomeObject - { -- public $name; -+ public string $name; - - public function __construct(string $name) - { - $this->name = $name; - } - } -``` - -
- ### TypedPropertyFromStrictConstructorRector Add typed properties based only on strict constructor types diff --git a/phpstan.neon b/phpstan.neon index 1da6e7e362a..36a4b4a7322 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -522,19 +522,14 @@ parameters: message: '#Unreachable statement \- code above always terminates#' paths: - rules/TypeDeclaration/Rector/Property/TypedPropertyFromStrictConstructorReadonlyClassRector.php - - rules/CodingStyle/Rector/Switch_/BinarySwitchToIfElseRector.php # deprecated - - '#Fetching class constant class of deprecated class Rector\\TypeDeclaration\\Rector\\Property\\TypedPropertyFromStrictConstructorReadonlyClassRector#' - '#Class "Rector\\Php71\\Rector\\FuncCall\\CountOnNullRector" is missing @see annotation with test case class reference#' - '#Register "Rector\\Php71\\Rector\\FuncCall\\CountOnNullRector" service to "php71\.php" config set#' # dev rule - '#Class "Rector\\Utils\\Rector\\MoveAbstractRectorToChildrenRector" is missing @see annotation with test case class reference#' - # deprecated parent property - - '#Fetching class constant class of deprecated class Rector\\CodingStyle\\Rector\\Switch_\\BinarySwitchToIfElseRector#' - - path: rules/Transform/Rector/Attribute/AttributeKeyToClassConstFetchRector.php message: "#Method \"processToClassConstFetch\\(\\)\" returns bool type, so the name should start with is/has/was#" diff --git a/rules/CodingStyle/Rector/Switch_/BinarySwitchToIfElseRector.php b/rules/CodingStyle/Rector/Switch_/BinarySwitchToIfElseRector.php deleted file mode 100644 index 3c8206060c0..00000000000 --- a/rules/CodingStyle/Rector/Switch_/BinarySwitchToIfElseRector.php +++ /dev/null @@ -1,64 +0,0 @@ -> - */ - public function getNodeTypes(): array - { - return [Switch_::class]; - } - - /** - * @param Switch_ $node - */ - public function refactor(Node $node): ?Node - { - trigger_error(sprintf( - 'The "%s" rule is deprecated as prevents refactoring to match (), use PHPStan, manual handling and PHP 8.0 upgrade set instead.', - self::class - ), E_USER_ERROR); - - return null; - } -} diff --git a/rules/TypeDeclaration/Rector/Property/TypedPropertyFromStrictConstructorReadonlyClassRector.php b/rules/TypeDeclaration/Rector/Property/TypedPropertyFromStrictConstructorReadonlyClassRector.php deleted file mode 100644 index 6b041d0d196..00000000000 --- a/rules/TypeDeclaration/Rector/Property/TypedPropertyFromStrictConstructorReadonlyClassRector.php +++ /dev/null @@ -1,89 +0,0 @@ -name = $name; - } -} -CODE_SAMPLE - - , - <<<'CODE_SAMPLE' -/** - * @immutable - */ -class SomeObject -{ - public string $name; - - public function __construct(string $name) - { - $this->name = $name; - } -} -CODE_SAMPLE - ), - - ] - ); - } - - /** - * @return array> - */ - public function getNodeTypes(): array - { - return [Class_::class]; - } - - /** - * @param Class_ $node - */ - public function refactorWithScope(Node $node, Scope $scope): ?Node - { - trigger_error(sprintf( - 'The "%s" rule is deprecated as based on docblock and public elements. Use private properties and property promotion rules instead.', - self::class - ), E_USER_ERROR); - - return null; - } - - public function provideMinPhpVersion(): int - { - return PhpVersionFeature::TYPED_PROPERTIES; - } -} diff --git a/utils/Command/MissingInSetCommand.php b/utils/Command/MissingInSetCommand.php index cc7a49e6c26..0a28cbc0d5f 100644 --- a/utils/Command/MissingInSetCommand.php +++ b/utils/Command/MissingInSetCommand.php @@ -5,12 +5,10 @@ namespace Rector\Utils\Command; use Nette\Utils\Strings; -use Rector\CodingStyle\Rector\Switch_\BinarySwitchToIfElseRector; use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Php71\Rector\FuncCall\CountOnNullRector; use Rector\Privatization\Rector\Class_\FinalizeClassesWithoutChildrenCollectorRector; use Rector\TypeDeclaration\Rector\BooleanAnd\BinaryOpNullableToInstanceofRector; -use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictConstructorReadonlyClassRector; use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictGetterMethodReturnTypeRector; use Rector\TypeDeclaration\Rector\StmtsAwareInterface\DeclareStrictTypesRector; use Rector\TypeDeclaration\Rector\While_\WhileNullableToInstanceofRector; @@ -36,9 +34,7 @@ final class MissingInSetCommand extends Command // collectors FinalizeClassesWithoutChildrenCollectorRector::class, // deprecated - TypedPropertyFromStrictConstructorReadonlyClassRector::class, TypedPropertyFromStrictGetterMethodReturnTypeRector::class, - BinarySwitchToIfElseRector::class, CountOnNullRector::class, ];