Skip to content

Commit

Permalink
Updated Rector to commit ef003b2458043b677bdd72522439bd80afb44a2c
Browse files Browse the repository at this point in the history
rectorphp/rector-src@ef003b2 refactor: add support for Custom Skip Voters (#5002)
  • Loading branch information
TomasVotruba committed Sep 12, 2023
1 parent ac9f7b5 commit f8df046
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 18 deletions.
16 changes: 10 additions & 6 deletions packages/Skipper/Skipper/Skipper.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
use Rector\Core\Contract\Rector\RectorInterface;
use Rector\Core\ProcessAnalyzer\RectifiedAnalyzer;
use Rector\Skipper\Contract\SkipVoterInterface;
use Rector\Skipper\SkipVoter\ClassSkipVoter;
use Rector\Skipper\SkipVoter\PathSkipVoter;
use RectorPrefix202309\Webmozart\Assert\Assert;
/**
* @api
* @see \Rector\Tests\Skipper\Skipper\SkipperTest
Expand All @@ -20,18 +19,23 @@ final class Skipper
* @var \Rector\Core\ProcessAnalyzer\RectifiedAnalyzer
*/
private $rectifiedAnalyzer;
/**
* @var array<SkipVoterInterface>
* @readonly
*/
private $skipVoters;
/**
* @var string
*/
private const FILE_ELEMENT = 'file_elements';
/**
* @var SkipVoterInterface[]
* @param array<SkipVoterInterface> $skipVoters
*/
private $skipVoters = [];
public function __construct(ClassSkipVoter $classSkipVoter, PathSkipVoter $pathSkipVoter, RectifiedAnalyzer $rectifiedAnalyzer)
public function __construct(RectifiedAnalyzer $rectifiedAnalyzer, array $skipVoters)
{
$this->rectifiedAnalyzer = $rectifiedAnalyzer;
$this->skipVoters = [$classSkipVoter, $pathSkipVoter];
$this->skipVoters = $skipVoters;
Assert::allIsInstanceOf($this->skipVoters, SkipVoterInterface::class);
}
/**
* @param string|object $element
Expand Down
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 = 'ffa43a11e01a594d3aaafe4eb5f09f4394e90019';
public const PACKAGE_VERSION = 'ef003b2458043b677bdd72522439bd80afb44a2c';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-09-12 09:43:41';
public const RELEASE_DATE = '2023-09-12 10:10:20';
/**
* @var int
*/
Expand Down
9 changes: 9 additions & 0 deletions src/DependencyInjection/LazyContainerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,10 @@
use Rector\PHPStanStaticTypeMapper\TypeMapper\TypeWithClassNameTypeMapper;
use Rector\PHPStanStaticTypeMapper\TypeMapper\VoidTypeMapper;
use Rector\PostRector\Application\PostFileProcessor;
use Rector\Skipper\Contract\SkipVoterInterface;
use Rector\Skipper\Skipper\Skipper;
use Rector\Skipper\SkipVoter\ClassSkipVoter;
use Rector\Skipper\SkipVoter\PathSkipVoter;
use Rector\StaticTypeMapper\Contract\PhpDocParser\PhpDocTypeMapperInterface;
use Rector\StaticTypeMapper\Contract\PhpParser\PhpParserNodeMapperInterface;
use Rector\StaticTypeMapper\Mapper\PhpParserNodeMapper;
Expand Down Expand Up @@ -228,6 +231,10 @@ final class LazyContainerFactory
* @var array<class-string<PhpParserNodeMapperInterface>>
*/
private const PHP_PARSER_NODE_MAPPER_CLASSES = [ExprNodeMapper::class, FullyQualifiedNodeMapper::class, IdentifierNodeMapper::class, IntersectionTypeNodeMapper::class, NameNodeMapper::class, NullableTypeNodeMapper::class, StringNodeMapper::class, UnionTypeNodeMapper::class];
/**
* @var array<class-string<SkipVoterInterface>>
*/
private const SKIP_VOTER_CLASSES = [ClassSkipVoter::class, PathSkipVoter::class];
/**
* @api used as next rectorConfig factory
*/
Expand Down Expand Up @@ -294,6 +301,8 @@ public function create() : RectorConfig
$rectorConfig->when(NodeTypeResolver::class)->needs('$nodeTypeResolvers')->giveTagged(NodeTypeResolverInterface::class);
// node name resolvers
$rectorConfig->when(NodeNameResolver::class)->needs('$nodeNameResolvers')->giveTagged(NodeNameResolverInterface::class);
$rectorConfig->when(Skipper::class)->needs('$skipVoters')->giveTagged(SkipVoterInterface::class);
$this->registerTagged($rectorConfig, self::SKIP_VOTER_CLASSES, SkipVoterInterface::class);
$rectorConfig->afterResolving(AbstractRector::class, static function (AbstractRector $rector, Container $container) : void {
$rector->autowire($container->make(NodeNameResolver::class), $container->make(NodeTypeResolver::class), $container->make(SimpleCallableNodeTraverser::class), $container->make(NodeFactory::class), $container->make(PhpDocInfoFactory::class), $container->make(StaticTypeMapper::class), $container->make(Skipper::class), $container->make(ValueResolver::class), $container->make(BetterNodeFinder::class), $container->make(NodeComparator::class), $container->make(CurrentFileProvider::class), $container->make(CreatedByRuleDecorator::class), $container->make(ChangedNodeScopeRefresher::class));
});
Expand Down
2 changes: 1 addition & 1 deletion vendor/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@

require_once __DIR__ . '/composer/autoload_real.php';

return ComposerAutoloaderInit217babcaf8c629b22d25c1ebdb16480a::getLoader();
return ComposerAutoloaderInit546d13250022c5fbfb7b0feeb9130391::getLoader();
10 changes: 5 additions & 5 deletions vendor/composer/autoload_real.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// autoload_real.php @generated by Composer

class ComposerAutoloaderInit217babcaf8c629b22d25c1ebdb16480a
class ComposerAutoloaderInit546d13250022c5fbfb7b0feeb9130391
{
private static $loader;

Expand All @@ -22,17 +22,17 @@ public static function getLoader()
return self::$loader;
}

spl_autoload_register(array('ComposerAutoloaderInit217babcaf8c629b22d25c1ebdb16480a', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit546d13250022c5fbfb7b0feeb9130391', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit217babcaf8c629b22d25c1ebdb16480a', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit546d13250022c5fbfb7b0feeb9130391', 'loadClassLoader'));

require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit217babcaf8c629b22d25c1ebdb16480a::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit546d13250022c5fbfb7b0feeb9130391::getInitializer($loader));

$loader->setClassMapAuthoritative(true);
$loader->register(true);

$filesToLoad = \Composer\Autoload\ComposerStaticInit217babcaf8c629b22d25c1ebdb16480a::$files;
$filesToLoad = \Composer\Autoload\ComposerStaticInit546d13250022c5fbfb7b0feeb9130391::$files;
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
Expand Down
8 changes: 4 additions & 4 deletions vendor/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Composer\Autoload;

class ComposerStaticInit217babcaf8c629b22d25c1ebdb16480a
class ComposerStaticInit546d13250022c5fbfb7b0feeb9130391
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
Expand Down Expand Up @@ -2592,9 +2592,9 @@ class ComposerStaticInit217babcaf8c629b22d25c1ebdb16480a
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit217babcaf8c629b22d25c1ebdb16480a::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit217babcaf8c629b22d25c1ebdb16480a::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit217babcaf8c629b22d25c1ebdb16480a::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit546d13250022c5fbfb7b0feeb9130391::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit546d13250022c5fbfb7b0feeb9130391::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit546d13250022c5fbfb7b0feeb9130391::$classMap;

}, null, ClassLoader::class);
}
Expand Down

0 comments on commit f8df046

Please sign in to comment.