From 0d08800f73fcaf6354a5bf364e26868c3366231f Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Wed, 6 Sep 2023 11:54:03 +0200 Subject: [PATCH 1/5] Remove deprecated NonPhpRectorInterface --- packages/Config/RectorConfig.php | 22 ++----------------- phpstan.neon | 5 ----- src/Contract/Rector/NonPhpRectorInterface.php | 13 ----------- 3 files changed, 2 insertions(+), 38 deletions(-) delete mode 100644 src/Contract/Rector/NonPhpRectorInterface.php diff --git a/packages/Config/RectorConfig.php b/packages/Config/RectorConfig.php index 6651667d5ec..d8f09dc2dbd 100644 --- a/packages/Config/RectorConfig.php +++ b/packages/Config/RectorConfig.php @@ -9,7 +9,6 @@ use Rector\Core\Configuration\Option; use Rector\Core\Configuration\Parameter\SimpleParameterProvider; use Rector\Core\Contract\Rector\ConfigurableRectorInterface; -use Rector\Core\Contract\Rector\NonPhpRectorInterface; use Rector\Core\Contract\Rector\RectorInterface; use Rector\Core\Exception\ShouldNotHappenException; use Rector\Core\FileSystem\FilesystemTweaker; @@ -178,7 +177,7 @@ public function ruleWithConfiguration(string $rectorClass, array $configuration) ); $this->singleton($rectorClass); - $this->tagRectorService($rectorClass); + $this->tag($rectorClass, RectorInterface::class); $this->afterResolving($rectorClass, function (ConfigurableRectorInterface $configurableRector) use ( $rectorClass @@ -200,7 +199,7 @@ public function rule(string $rectorClass): void Assert::isAOf($rectorClass, RectorInterface::class); $this->singleton($rectorClass); - $this->tagRectorService($rectorClass); + $this->tag($rectorClass, RectorInterface::class); if (is_a($rectorClass, AbstractScopeAwareRector::class, true)) { $this->extend( @@ -389,23 +388,6 @@ private function resolveDuplicatedValues(array $values): array return array_unique($duplicates); } - /** - * @param class-string $rectorClass - */ - private function tagRectorService(string $rectorClass): void - { - $this->tag($rectorClass, RectorInterface::class); - - if (is_a($rectorClass, NonPhpRectorInterface::class, true)) { - trigger_error(sprintf( - 'The "%s" interface of "%s" rule is deprecated. Rector will process only PHP code, as designed to with AST. For another file format, use custom tooling.', - NonPhpRectorInterface::class, - $rectorClass, - )); - exit(); - } - } - /** * @param string[] $rectorClasses */ diff --git a/phpstan.neon b/phpstan.neon index f39ec55eb37..8fd10c00325 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -592,11 +592,6 @@ parameters: message: '#Do not name "d", shorter than 2 chars#' path: tests/debug_functions.php - # deprecated - - - message: '#Fetching class constant class of deprecated class Rector\\Core\\Contract\\Rector\\NonPhpRectorInterface#' - path: packages/Config/* - # method signature kept for symmetry of hasParentClassMethod() with getParentClassMethod() - message: '#Parameters should use "PhpParser\\Node\\Stmt\\ClassMethod" types as the only types passed to this method#' diff --git a/src/Contract/Rector/NonPhpRectorInterface.php b/src/Contract/Rector/NonPhpRectorInterface.php deleted file mode 100644 index 0c468b762bc..00000000000 --- a/src/Contract/Rector/NonPhpRectorInterface.php +++ /dev/null @@ -1,13 +0,0 @@ - Date: Wed, 6 Sep 2023 11:54:35 +0200 Subject: [PATCH 2/5] remove deprecated PseudoNamespaceToNamespaceRector --- phpstan.neon | 2 - .../PseudoNamespaceToNamespaceRector.php | 73 ------------------- .../PseudoNamespaceToNamespace.php | 33 --------- 3 files changed, 108 deletions(-) delete mode 100644 rules/Renaming/Rector/FileWithoutNamespace/PseudoNamespaceToNamespaceRector.php delete mode 100644 rules/Renaming/ValueObject/PseudoNamespaceToNamespace.php diff --git a/phpstan.neon b/phpstan.neon index 8fd10c00325..8a9d77391a4 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -576,8 +576,6 @@ parameters: message: '#Public method "Rector\\Core\\DependencyInjection\\RectorContainerFactory\:\:createFromBootstrapConfigs\(\)" is never used#' path: src/DependencyInjection/RectorContainerFactory.php - - '#Class "Rector\\Renaming\\Rector\\FileWithoutNamespace\\PseudoNamespaceToNamespaceRector" is missing @see annotation with test case class reference#' - # chicken/egg - message: '#Function "(d|dd)\(\)" cannot be used/left in the code#' diff --git a/rules/Renaming/Rector/FileWithoutNamespace/PseudoNamespaceToNamespaceRector.php b/rules/Renaming/Rector/FileWithoutNamespace/PseudoNamespaceToNamespaceRector.php deleted file mode 100644 index f192a77c67c..00000000000 --- a/rules/Renaming/Rector/FileWithoutNamespace/PseudoNamespaceToNamespaceRector.php +++ /dev/null @@ -1,73 +0,0 @@ -> - */ - public function getNodeTypes(): array - { - // property, method - return [FileWithoutNamespace::class, Namespace_::class]; - } - - /** - * @param Namespace_|FileWithoutNamespace $node - */ - public function refactor(Node $node): ?Node - { - $errorMessage = sprintf( - 'Rule "%s" is deprecated, as unreliable and too dynamic. Use more robuts RenameClassRector instead.', - self::class - ); - trigger_error($errorMessage, E_USER_WARNING); - sleep(3); - - return null; - } - - /** - * @param mixed[] $configuration - */ - public function configure(array $configuration): void - { - // for BC - } -} diff --git a/rules/Renaming/ValueObject/PseudoNamespaceToNamespace.php b/rules/Renaming/ValueObject/PseudoNamespaceToNamespace.php deleted file mode 100644 index d1fa6305b96..00000000000 --- a/rules/Renaming/ValueObject/PseudoNamespaceToNamespace.php +++ /dev/null @@ -1,33 +0,0 @@ -namespacePrefix; - } - - /** - * @return string[] - */ - public function getExcludedClasses(): array - { - return $this->excludedClasses; - } -} From 1503c894302e804204d5886b9ae008bcfcfdb5db Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Wed, 6 Sep 2023 12:01:23 +0200 Subject: [PATCH 3/5] remove deprecated and empty mysql to mysqli set --- config/set/mysql-to-mysqli.php | 9 --------- packages/Set/ValueObject/SetList.php | 6 ------ 2 files changed, 15 deletions(-) delete mode 100644 config/set/mysql-to-mysqli.php diff --git a/config/set/mysql-to-mysqli.php b/config/set/mysql-to-mysqli.php deleted file mode 100644 index 3fd8604f1fa..00000000000 --- a/config/set/mysql-to-mysqli.php +++ /dev/null @@ -1,9 +0,0 @@ - Date: Wed, 6 Sep 2023 12:01:48 +0200 Subject: [PATCH 4/5] remove deprecated createIfStmt() method --- src/NodeManipulator/IfManipulator.php | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/NodeManipulator/IfManipulator.php b/src/NodeManipulator/IfManipulator.php index 050aa2cc9fb..6acd18e5380 100644 --- a/src/NodeManipulator/IfManipulator.php +++ b/src/NodeManipulator/IfManipulator.php @@ -186,16 +186,6 @@ public function isIfWithoutElseAndElseIfs(If_ $if): bool return $if->elseifs === []; } - /** - * @deprecated Create If_ directly, this is simple new with no added value - */ - public function createIfStmt(Expr $condExpr, Stmt $stmt): If_ - { - return new If_($condExpr, [ - 'stmts' => [$stmt], - ]); - } - private function matchComparedAndReturnedNode(NotIdentical $notIdentical, Return_ $return): ?Expr { if ($this->nodeComparator->areNodesEqual( From 841ca93715adf98b79c958d047c8c18debdf777a Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Wed, 6 Sep 2023 12:04:44 +0200 Subject: [PATCH 5/5] notes --- src/DependencyInjection/LazyContainerFactory.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/DependencyInjection/LazyContainerFactory.php b/src/DependencyInjection/LazyContainerFactory.php index 23c339ea307..30100862c49 100644 --- a/src/DependencyInjection/LazyContainerFactory.php +++ b/src/DependencyInjection/LazyContainerFactory.php @@ -710,10 +710,8 @@ static function ( ScopeResolverNodeVisitorInterface::class ); - // phpstan factory $this->createPHPStanServices($rectorConfig); - // @todo add base node visitors $rectorConfig->when(PhpDocNodeMapper::class) ->needs('$phpDocNodeVisitors') ->giveTagged(BasePhpDocNodeVisitorInterface::class);