Skip to content

Commit

Permalink
Updated Rector to commit 861a8808e7516c74b7e41a884076eac35f60a14f
Browse files Browse the repository at this point in the history
rectorphp/rector-src@861a880 [Php82] Skip usage of already RecursiveDirectoryIterator::SKIP_DOTS on FilesystemIteratorSkipDotsRector (#5712)
  • Loading branch information
TomasVotruba committed Mar 11, 2024
1 parent 7660d57 commit ecd6151
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
21 changes: 12 additions & 9 deletions rules/Php82/Rector/New_/FilesystemIteratorSkipDotsRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
{
Expand Down Expand Up @@ -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);
}
}
4 changes: 2 additions & 2 deletions src/Application/VersionResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
3 changes: 1 addition & 2 deletions src/Autoloading/BootstrapFilesIncluder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit ecd6151

Please sign in to comment.