Updated Rector to commit bf4cfa566386963da42447dbad93c5d6a94b5b93

bf4cfa5663 [PHPUnit] Fix extreemely slow PHPUnit run on data providers with objects (#4823)
This commit is contained in:
Tomas Votruba 2023-08-20 17:46:04 +00:00
parent 98e671cd4d
commit cfc8e32b1a
7 changed files with 42 additions and 43 deletions

View File

@ -50,7 +50,7 @@ final class BetterPhpDocParser extends PhpDocParser
/**
* @param PhpDocNodeDecoratorInterface[] $phpDocNodeDecorators
*/
public function __construct(TypeParser $typeParser, ConstExprParser $constExprParser, CurrentNodeProvider $currentNodeProvider, TokenIteratorFactory $tokenIteratorFactory, iterable $phpDocNodeDecorators, PrivatesAccessor $privatesAccessor = null)
public function __construct(TypeParser $typeParser, ConstExprParser $constExprParser, CurrentNodeProvider $currentNodeProvider, TokenIteratorFactory $tokenIteratorFactory, array $phpDocNodeDecorators, PrivatesAccessor $privatesAccessor = null)
{
$privatesAccessor = $privatesAccessor ?? new PrivatesAccessor();
$this->currentNodeProvider = $currentNodeProvider;

View File

@ -5,10 +5,7 @@ namespace Rector\Testing\PHPUnit;
use PHPUnit\Framework\TestCase;
use Rector\Config\RectorConfig;
use Rector\Core\Contract\Rector\RectorInterface;
use Rector\Core\DependencyInjection\LazyContainerFactory;
use Rector\Core\Rector\AbstractRector;
use Rector\Core\Util\Reflection\PrivatesAccessor;
abstract class AbstractLazyTestCase extends TestCase
{
/**
@ -43,31 +40,4 @@ abstract class AbstractLazyTestCase extends TestCase
}
return self::$rectorConfig;
}
protected function forgetRectorsRules() : void
{
$rectorConfig = self::getContainer();
// 1. forget instance first, then remove tags
$rectors = $rectorConfig->tagged(RectorInterface::class);
foreach ($rectors as $rector) {
$rectorConfig->offsetUnset(\get_class($rector));
}
// 2. remove all tagged rules
$privatesAccessor = new PrivatesAccessor();
$privatesAccessor->propertyClosure($rectorConfig, 'tags', static function (array $tags) : array {
unset($tags[RectorInterface::class]);
return $tags;
});
// 3. remove after binding too, to avoid setting configuration over and over again
$privatesAccessor->propertyClosure($rectorConfig, 'afterResolvingCallbacks', static function (array $afterResolvingCallbacks) : array {
foreach (\array_keys($afterResolvingCallbacks) as $key) {
if ($key === AbstractRector::class) {
continue;
}
if (\is_a($key, RectorInterface::class, \true)) {
unset($afterResolvingCallbacks[$key]);
}
}
return $afterResolvingCallbacks;
});
}
}

View File

@ -19,6 +19,8 @@ use Rector\Core\Configuration\RenamedClassesDataCollector;
use Rector\Core\Contract\Rector\RectorInterface;
use Rector\Core\Exception\ShouldNotHappenException;
use Rector\Core\PhpParser\NodeTraverser\RectorNodeTraverser;
use Rector\Core\Rector\AbstractRector;
use Rector\Core\Util\Reflection\PrivatesAccessor;
use Rector\NodeTypeResolver\Reflection\BetterReflection\SourceLocatorProvider\DynamicSourceLocatorProvider;
use Rector\Testing\Contract\RectorTestInterface;
use Rector\Testing\Fixture\FixtureFileFinder;
@ -133,6 +135,33 @@ abstract class AbstractRectorTestCase extends \Rector\Testing\PHPUnit\AbstractLa
FileSystem::write($inputFilePath, $inputFileContents);
$this->doTestFileMatchesExpectedContent($inputFilePath, $expectedFileContents, $fixtureFilePath);
}
protected function forgetRectorsRules() : void
{
$rectorConfig = self::getContainer();
// 1. forget instance first, then remove tags
$rectors = $rectorConfig->tagged(RectorInterface::class);
foreach ($rectors as $rector) {
$rectorConfig->offsetUnset(\get_class($rector));
}
// 2. remove all tagged rules
$privatesAccessor = new PrivatesAccessor();
$privatesAccessor->propertyClosure($rectorConfig, 'tags', static function (array $tags) : array {
unset($tags[RectorInterface::class]);
return $tags;
});
// 3. remove after binding too, to avoid setting configuration over and over again
$privatesAccessor->propertyClosure($rectorConfig, 'afterResolvingCallbacks', static function (array $afterResolvingCallbacks) : array {
foreach (\array_keys($afterResolvingCallbacks) as $key) {
if ($key === AbstractRector::class) {
continue;
}
if (\is_a($key, RectorInterface::class, \true)) {
unset($afterResolvingCallbacks[$key]);
}
}
return $afterResolvingCallbacks;
});
}
private function includePreloadFilesAndScoperAutoload() : void
{
if (\file_exists(__DIR__ . '/../../../preload.php')) {

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = 'bdad8bd4a5e4cdbcd65bdf942119750e0c7be1a8';
public const PACKAGE_VERSION = 'bf4cfa566386963da42447dbad93c5d6a94b5b93';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-08-20 13:17:15';
public const RELEASE_DATE = '2023-08-20 19:42:35';
/**
* @var int
*/

2
vendor/autoload.php vendored
View File

@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit86cc5ae84502facea98f5bddc7101426::getLoader();
return ComposerAutoloaderInitfc271f918752be2aff0c1f71bd387b88::getLoader();

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit86cc5ae84502facea98f5bddc7101426
class ComposerAutoloaderInitfc271f918752be2aff0c1f71bd387b88
{
private static $loader;
@ -22,17 +22,17 @@ class ComposerAutoloaderInit86cc5ae84502facea98f5bddc7101426
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit86cc5ae84502facea98f5bddc7101426', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInitfc271f918752be2aff0c1f71bd387b88', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit86cc5ae84502facea98f5bddc7101426', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInitfc271f918752be2aff0c1f71bd387b88', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit86cc5ae84502facea98f5bddc7101426::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInitfc271f918752be2aff0c1f71bd387b88::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$filesToLoad = \Composer\Autoload\ComposerStaticInit86cc5ae84502facea98f5bddc7101426::$files;
$filesToLoad = \Composer\Autoload\ComposerStaticInitfc271f918752be2aff0c1f71bd387b88::$files;
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInit86cc5ae84502facea98f5bddc7101426
class ComposerStaticInitfc271f918752be2aff0c1f71bd387b88
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
@ -2611,9 +2611,9 @@ class ComposerStaticInit86cc5ae84502facea98f5bddc7101426
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit86cc5ae84502facea98f5bddc7101426::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit86cc5ae84502facea98f5bddc7101426::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit86cc5ae84502facea98f5bddc7101426::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInitfc271f918752be2aff0c1f71bd387b88::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitfc271f918752be2aff0c1f71bd387b88::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitfc271f918752be2aff0c1f71bd387b88::$classMap;
}, null, ClassLoader::class);
}