From 88b118d7942d58182867b69729d2d4f401d92823 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Wed, 24 Aug 2022 07:54:32 +0000 Subject: [PATCH] Updated Rector to commit 58edce71bb42b06df87e863ee9bf3df4c7b65e27 https://github.com/rectorphp/rector-src/commit/58edce71bb42b06df87e863ee9bf3df4c7b65e27 [VendorPatch] Register nikic-php-parser-lib-phpparser-node-stmt-namespace-php into vendor-patches list (#2825) --- .../Stmt/RemoveUnreachableStatementRector.php | 6 +++--- src/Application/ChangedNodeScopeRefresher.php | 3 +-- src/Application/VersionResolver.php | 4 ++-- src/NodeAnalyzer/TerminatedNodeAnalyzer.php | 10 +++++++++- vendor/autoload.php | 2 +- vendor/composer/autoload_real.php | 14 +++++++------- vendor/composer/autoload_static.php | 8 ++++---- vendor/composer/installed.json | 3 ++- vendor/nikic/php-parser/PATCHES.txt | 4 ++++ .../lib/PhpParser/Node/Stmt/Namespace_.php | 3 ++- 10 files changed, 35 insertions(+), 22 deletions(-) diff --git a/rules/DeadCode/Rector/Stmt/RemoveUnreachableStatementRector.php b/rules/DeadCode/Rector/Stmt/RemoveUnreachableStatementRector.php index ac06c4c7092..fd6be3ca6f8 100644 --- a/rules/DeadCode/Rector/Stmt/RemoveUnreachableStatementRector.php +++ b/rules/DeadCode/Rector/Stmt/RemoveUnreachableStatementRector.php @@ -64,7 +64,7 @@ CODE_SAMPLE return null; } $originalStmts = $node->stmts; - $cleanedStmts = $this->processCleanUpUnreachabelStmts($node->stmts); + $cleanedStmts = $this->processCleanUpUnreachabelStmts($node, $node->stmts); if ($cleanedStmts === $originalStmts) { return null; } @@ -75,7 +75,7 @@ CODE_SAMPLE * @param Stmt[] $stmts * @return Stmt[] */ - private function processCleanUpUnreachabelStmts(array $stmts) : array + private function processCleanUpUnreachabelStmts(StmtsAwareInterface $stmtsAware, array $stmts) : array { foreach ($stmts as $key => $stmt) { if (!isset($stmts[$key - 1])) { @@ -83,7 +83,7 @@ CODE_SAMPLE } $previousStmt = $stmts[$key - 1]; // unset... - if ($this->terminatedNodeAnalyzer->isAlwaysTerminated($previousStmt, $stmt)) { + if ($this->terminatedNodeAnalyzer->isAlwaysTerminated($stmtsAware, $previousStmt, $stmt)) { \array_splice($stmts, $key); return $stmts; } diff --git a/src/Application/ChangedNodeScopeRefresher.php b/src/Application/ChangedNodeScopeRefresher.php index 6339b459bfc..744375a9265 100644 --- a/src/Application/ChangedNodeScopeRefresher.php +++ b/src/Application/ChangedNodeScopeRefresher.php @@ -21,7 +21,6 @@ use PhpParser\Node\Stmt\ClassMethod; use PhpParser\Node\Stmt\Expression; use PhpParser\Node\Stmt\Function_; use PhpParser\Node\Stmt\If_; -use PhpParser\Node\Stmt\Namespace_; use PhpParser\Node\Stmt\Property; use PhpParser\Node\Stmt\Switch_; use PhpParser\Node\Stmt\TryCatch; @@ -99,7 +98,7 @@ final class ChangedNodeScopeRefresher } private function reIndexNodeAttributes(Node $node) : void { - if (($node instanceof Namespace_ || $node instanceof ClassLike || $node instanceof StmtsAwareInterface) && $node->stmts !== null) { + if (($node instanceof ClassLike || $node instanceof StmtsAwareInterface) && $node->stmts !== null) { $node->stmts = \array_values($node->stmts); } if ($node instanceof FunctionLike) { diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index 903c07c5844..bd41cf95c4d 100644 --- a/src/Application/VersionResolver.php +++ b/src/Application/VersionResolver.php @@ -17,12 +17,12 @@ final class VersionResolver * @api * @var string */ - public const PACKAGE_VERSION = 'feda30ad318904b29f342ee1cfe4d81c103d4c40'; + public const PACKAGE_VERSION = '58edce71bb42b06df87e863ee9bf3df4c7b65e27'; /** * @api * @var string */ - public const RELEASE_DATE = '2022-08-24 09:25:46'; + public const RELEASE_DATE = '2022-08-24 14:50:04'; /** * @var int */ diff --git a/src/NodeAnalyzer/TerminatedNodeAnalyzer.php b/src/NodeAnalyzer/TerminatedNodeAnalyzer.php index 236d4ae308c..e8d58936e1d 100644 --- a/src/NodeAnalyzer/TerminatedNodeAnalyzer.php +++ b/src/NodeAnalyzer/TerminatedNodeAnalyzer.php @@ -8,19 +8,24 @@ use PhpParser\Node\Expr; use PhpParser\Node\Expr\Exit_; use PhpParser\Node\Stmt; use PhpParser\Node\Stmt\Break_; +use PhpParser\Node\Stmt\ClassLike; use PhpParser\Node\Stmt\Continue_; use PhpParser\Node\Stmt\Else_; use PhpParser\Node\Stmt\Expression; use PhpParser\Node\Stmt\Finally_; +use PhpParser\Node\Stmt\Function_; use PhpParser\Node\Stmt\Goto_; use PhpParser\Node\Stmt\If_; use PhpParser\Node\Stmt\InlineHTML; use PhpParser\Node\Stmt\Label; +use PhpParser\Node\Stmt\Namespace_; use PhpParser\Node\Stmt\Nop; use PhpParser\Node\Stmt\Return_; use PhpParser\Node\Stmt\Switch_; use PhpParser\Node\Stmt\Throw_; use PhpParser\Node\Stmt\TryCatch; +use Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface; +use Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace; final class TerminatedNodeAnalyzer { /** @@ -39,11 +44,14 @@ final class TerminatedNodeAnalyzer * @var array> */ private const ALLOWED_CONTINUE_CURRENT_STMTS = [InlineHTML::class, Nop::class]; - public function isAlwaysTerminated(Stmt $node, Stmt $currentStmt) : bool + public function isAlwaysTerminated(StmtsAwareInterface $stmtsAware, Stmt $node, Stmt $currentStmt) : bool { if (\in_array(\get_class($currentStmt), self::ALLOWED_CONTINUE_CURRENT_STMTS, \true)) { return \false; } + if (($stmtsAware instanceof FileWithoutNamespace || $stmtsAware instanceof Namespace_) && ($currentStmt instanceof ClassLike || $currentStmt instanceof Function_)) { + return \false; + } if (!\in_array(\get_class($node), self::TERMINABLE_NODES_BY_ITS_STMTS, \true)) { return $this->isTerminatedNode($node, $currentStmt); } diff --git a/vendor/autoload.php b/vendor/autoload.php index c6e315ca1ad..0982ef27cf6 100644 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -9,4 +9,4 @@ if (PHP_VERSION_ID < 50600) { require_once __DIR__ . '/composer/autoload_real.php'; -return ComposerAutoloaderInitf0dd96300d561a258f5be70df58f0989::getLoader(); +return ComposerAutoloaderInit23a203334751054f9dcaf69831e79efd::getLoader(); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index e8b8e4b7e79..a9e2d629828 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInitf0dd96300d561a258f5be70df58f0989 +class ComposerAutoloaderInit23a203334751054f9dcaf69831e79efd { private static $loader; @@ -22,19 +22,19 @@ class ComposerAutoloaderInitf0dd96300d561a258f5be70df58f0989 return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInitf0dd96300d561a258f5be70df58f0989', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInit23a203334751054f9dcaf69831e79efd', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); - spl_autoload_unregister(array('ComposerAutoloaderInitf0dd96300d561a258f5be70df58f0989', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInit23a203334751054f9dcaf69831e79efd', 'loadClassLoader')); require __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInitf0dd96300d561a258f5be70df58f0989::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInit23a203334751054f9dcaf69831e79efd::getInitializer($loader)); $loader->setClassMapAuthoritative(true); $loader->register(true); - $includeFiles = \Composer\Autoload\ComposerStaticInitf0dd96300d561a258f5be70df58f0989::$files; + $includeFiles = \Composer\Autoload\ComposerStaticInit23a203334751054f9dcaf69831e79efd::$files; foreach ($includeFiles as $fileIdentifier => $file) { - composerRequiref0dd96300d561a258f5be70df58f0989($fileIdentifier, $file); + composerRequire23a203334751054f9dcaf69831e79efd($fileIdentifier, $file); } return $loader; @@ -46,7 +46,7 @@ class ComposerAutoloaderInitf0dd96300d561a258f5be70df58f0989 * @param string $file * @return void */ -function composerRequiref0dd96300d561a258f5be70df58f0989($fileIdentifier, $file) +function composerRequire23a203334751054f9dcaf69831e79efd($fileIdentifier, $file) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 19d5f89d8b5..1a521af79ec 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInitf0dd96300d561a258f5be70df58f0989 +class ComposerStaticInit23a203334751054f9dcaf69831e79efd { public static $files = array ( '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php', @@ -3258,9 +3258,9 @@ class ComposerStaticInitf0dd96300d561a258f5be70df58f0989 public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInitf0dd96300d561a258f5be70df58f0989::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInitf0dd96300d561a258f5be70df58f0989::$prefixDirsPsr4; - $loader->classMap = ComposerStaticInitf0dd96300d561a258f5be70df58f0989::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInit23a203334751054f9dcaf69831e79efd::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInit23a203334751054f9dcaf69831e79efd::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInit23a203334751054f9dcaf69831e79efd::$classMap; }, null, ClassLoader::class); } diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 54b3fdece32..10942a7966f 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -572,7 +572,8 @@ "https:\/\/raw.githubusercontent.com\/rectorphp\/vendor-patches\/main\/patches\/nikic-php-parser-lib-phpparser-node-stmt-foreach-php.patch", "https:\/\/raw.githubusercontent.com\/rectorphp\/vendor-patches\/main\/patches\/nikic-php-parser-lib-phpparser-node-stmt-if-php.patch", "https:\/\/raw.githubusercontent.com\/rectorphp\/vendor-patches\/main\/patches\/nikic-php-parser-lib-phpparser-node-stmt-case-php.patch", - "https:\/\/raw.githubusercontent.com\/rectorphp\/vendor-patches\/main\/patches\/nikic-php-parser-lib-phpparser-node-stmt-elseif-php.patch" + "https:\/\/raw.githubusercontent.com\/rectorphp\/vendor-patches\/main\/patches\/nikic-php-parser-lib-phpparser-node-stmt-elseif-php.patch", + "https:\/\/raw.githubusercontent.com\/rectorphp\/vendor-patches\/main\/patches\/nikic-php-parser-lib-phpparser-node-stmt-namespace-php.patch" ] }, "installation-source": "dist", diff --git a/vendor/nikic/php-parser/PATCHES.txt b/vendor/nikic/php-parser/PATCHES.txt index ce9002a1e0c..03f74407677 100644 --- a/vendor/nikic/php-parser/PATCHES.txt +++ b/vendor/nikic/php-parser/PATCHES.txt @@ -57,3 +57,7 @@ Source: https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/ Source: https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/nikic-php-parser-lib-phpparser-node-stmt-elseif-php.patch +14 +Source: https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/nikic-php-parser-lib-phpparser-node-stmt-namespace-php.patch + + diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Namespace_.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Namespace_.php index 0b329e689cc..4a7a7f613aa 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Namespace_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Namespace_.php @@ -4,7 +4,8 @@ declare (strict_types=1); namespace PhpParser\Node\Stmt; use PhpParser\Node; -class Namespace_ extends Node\Stmt +use Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface; +class Namespace_ extends Node\Stmt implements StmtsAwareInterface { /* For use in the "kind" attribute */ const KIND_SEMICOLON = 1;