From ecd615137eb50f7e7f530c05570fe89fc2d81a7c Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Mon, 11 Mar 2024 03:08:10 +0000 Subject: [PATCH] Updated Rector to commit 861a8808e7516c74b7e41a884076eac35f60a14f https://github.com/rectorphp/rector-src/commit/861a8808e7516c74b7e41a884076eac35f60a14f [Php82] Skip usage of already RecursiveDirectoryIterator::SKIP_DOTS on FilesystemIteratorSkipDotsRector (#5712) --- .../New_/FilesystemIteratorSkipDotsRector.php | 21 +++++++++++-------- src/Application/VersionResolver.php | 4 ++-- src/Autoloading/BootstrapFilesIncluder.php | 3 +-- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/rules/Php82/Rector/New_/FilesystemIteratorSkipDotsRector.php b/rules/Php82/Rector/New_/FilesystemIteratorSkipDotsRector.php index bcb7fda343af..60b382356006 100644 --- a/rules/Php82/Rector/New_/FilesystemIteratorSkipDotsRector.php +++ b/rules/Php82/Rector/New_/FilesystemIteratorSkipDotsRector.php @@ -3,7 +3,6 @@ declare (strict_types=1); namespace Rector\Php82\Rector\New_; -use FilesystemIterator; use PhpParser\Node; use PhpParser\Node\Arg; use PhpParser\Node\Expr; @@ -12,29 +11,29 @@ use PhpParser\Node\Expr\New_; use PhpParser\Node\Name\FullyQualified; use PHPStan\Type\ObjectType; -use Rector\NodeNameResolver\NodeNameResolver\ClassConstFetchNameResolver; +use Rector\PhpParser\Node\Value\ValueResolver; use Rector\Rector\AbstractRector; use Rector\ValueObject\PhpVersionFeature; use Rector\VersionBonding\Contract\MinPhpVersionInterface; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** - * @see \Rector\Tests\Php82\Rector\New_\FilesystemIteratorSkipDots\FilesystemIteratorSkipDotsRectorTest + * @see \Rector\Tests\Php82\Rector\New_\FilesystemIteratorSkipDotsRector\FilesystemIteratorSkipDotsRectorTest */ final class FilesystemIteratorSkipDotsRector extends AbstractRector implements MinPhpVersionInterface { /** * @readonly - * @var \Rector\NodeNameResolver\NodeNameResolver\ClassConstFetchNameResolver + * @var \Rector\PhpParser\Node\Value\ValueResolver */ - private $classConstFetchNameResolver; - public function __construct(ClassConstFetchNameResolver $classConstFetchNameResolver) + private $valueResolver; + public function __construct(ValueResolver $valueResolver) { - $this->classConstFetchNameResolver = $classConstFetchNameResolver; + $this->valueResolver = $valueResolver; } public function getRuleDefinition() : RuleDefinition { - return new RuleDefinition('Prior PHP 8.2 FilesystemIterator::SKIP_DOTS was always set and could not be removed, therefore FilesystemIterator::SKIP_DOTS is added in order to keep this behaviour.', [new CodeSample('new ' . FilesystemIterator::class . '(__DIR__, ' . FilesystemIterator::class . '::KEY_AS_FILENAME);', 'new ' . FilesystemIterator::class . '(__DIR__, ' . FilesystemIterator::class . '::KEY_AS_FILENAME | ' . FilesystemIterator::class . '::SKIP_DOTS);')]); + return new RuleDefinition('Prior PHP 8.2 FilesystemIterator::SKIP_DOTS was always set and could not be removed, therefore FilesystemIterator::SKIP_DOTS is added in order to keep this behaviour.', [new CodeSample('new FilesystemIterator(__DIR__, FilesystemIterator::KEY_AS_FILENAME);', 'new FilesystemIterator(__DIR__, FilesystemIterator::KEY_AS_FILENAME | FilesystemIterator::SKIP_DOTS);')]); } public function getNodeTypes() : array { @@ -90,6 +89,10 @@ private function isSkipDots(Expr $expr) : bool // can be anything return \true; } - return $this->classConstFetchNameResolver->resolve($expr, null) === 'FilesystemIterator::SKIP_DOTS'; + if (!\defined('FilesystemIterator::SKIP_DOTS')) { + return \true; + } + $value = \constant('FilesystemIterator::SKIP_DOTS'); + return $this->valueResolver->isValue($expr, $value); } } diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index 1ed12c9f8c8d..1e1a543f5839 100644 --- a/src/Application/VersionResolver.php +++ b/src/Application/VersionResolver.php @@ -19,12 +19,12 @@ final class VersionResolver * @api * @var string */ - public const PACKAGE_VERSION = '8ade0b9e46aff3e6f755a9561579cdc0c9eb9b0e'; + public const PACKAGE_VERSION = '861a8808e7516c74b7e41a884076eac35f60a14f'; /** * @api * @var string */ - public const RELEASE_DATE = '2024-03-11 09:21:31'; + public const RELEASE_DATE = '2024-03-11 10:05:54'; /** * @var int */ diff --git a/src/Autoloading/BootstrapFilesIncluder.php b/src/Autoloading/BootstrapFilesIncluder.php index 0764a65cd55b..d83b2077ffc0 100644 --- a/src/Autoloading/BootstrapFilesIncluder.php +++ b/src/Autoloading/BootstrapFilesIncluder.php @@ -3,7 +3,6 @@ declare (strict_types=1); namespace Rector\Autoloading; -use FilesystemIterator; use Rector\Configuration\Option; use Rector\Configuration\Parameter\SimpleParameterProvider; use Rector\Exception\ShouldNotHappenException; @@ -40,7 +39,7 @@ private function requireRectorStubs() : void if ($stubsRectorDirectory === \false) { return; } - $dir = new RecursiveDirectoryIterator($stubsRectorDirectory, RecursiveDirectoryIterator::SKIP_DOTS | FilesystemIterator::SKIP_DOTS); + $dir = new RecursiveDirectoryIterator($stubsRectorDirectory, RecursiveDirectoryIterator::SKIP_DOTS); /** @var SplFileInfo[] $stubs */ $stubs = new RecursiveIteratorIterator($dir); foreach ($stubs as $stub) {