Updated Rector to commit 81ba0c90bd

81ba0c90bd [Scoper] Remove PHPStanStubLoader: move to dedicated file to define native classes (#2249)
This commit is contained in:
Tomas Votruba 2022-05-07 09:29:04 +00:00
parent 2786be52f6
commit e1b8b2e468
11 changed files with 104 additions and 93 deletions

View File

@ -16,11 +16,11 @@ final class VersionResolver
/**
* @var string
*/
public const PACKAGE_VERSION = 'c2ade0583ccd8fe1413be641924f5b1576ffad8b';
public const PACKAGE_VERSION = '81ba0c90bd2ce5a56e5a1fd5df3fc4277357ed88';
/**
* @var string
*/
public const RELEASE_DATE = '2022-05-07 09:20:29';
public const RELEASE_DATE = '2022-05-07 16:21:59';
/**
* @var string
*/

View File

@ -13,7 +13,7 @@ final class BootstrapFilesIncluder
/**
* @var string[]
*/
private const STUBS = ['/../../stubs-rector/PHPUnit/Framework/TestCase.php', '/../../stubs-rector/Internal/EnumInterfaces.php'];
private const STUBS = ['Internal/EnumInterfaces.php', 'Internal/NativeClasses.php', 'PHPUnit/Framework/TestCase.php'];
/**
* @readonly
* @var \Symplify\PackageBuilder\Parameter\ParameterProvider
@ -44,8 +44,8 @@ final class BootstrapFilesIncluder
}
}
foreach (self::STUBS as $stub) {
if (\is_file(__DIR__ . $stub)) {
require_once __DIR__ . $stub;
if (\is_file(__DIR__ . '/../../stubs-rector/' . $stub)) {
require_once __DIR__ . '/../../stubs-rector/' . $stub;
}
}
}

View File

@ -7,7 +7,6 @@ use RectorPrefix20220507\Nette\Utils\FileSystem;
use RectorPrefix20220507\Psr\Container\ContainerInterface;
use Rector\Caching\Detector\ChangedFilesDetector;
use Rector\Core\Kernel\RectorKernel;
use Rector\Core\Stubs\PHPStanStubLoader;
use Rector\Core\ValueObject\Bootstrap\BootstrapConfigs;
use RectorPrefix20220507\Symfony\Component\Console\Style\SymfonyStyle;
final class RectorContainerFactory
@ -40,8 +39,6 @@ final class RectorContainerFactory
*/
private function createFromConfigs(array $configFiles) : \RectorPrefix20220507\Psr\Container\ContainerInterface
{
$phpStanStubLoader = new \Rector\Core\Stubs\PHPStanStubLoader();
$phpStanStubLoader->loadStubs();
$rectorKernel = new \Rector\Core\Kernel\RectorKernel();
return $rectorKernel->createFromConfigs($configFiles);
}

View File

@ -1,64 +0,0 @@
<?php
declare (strict_types=1);
namespace Rector\Core\Stubs;
final class PHPStanStubLoader
{
/**
* @var string[]
*/
private const STUBS = ['ReflectionUnionType.php', 'Attribute.php'];
/**
* @var string[]
*/
private const VENDOR_PATHS = [
// 1. relative path with composer require rector/rector and run vendor/bin/rector
'vendor',
// 2. relative path with composer require rector/rector with symlink run vendor/bin/rector
__DIR__ . '/../../vendor',
// 3. run outside project like in https://getrector.org/ from docker, so it look up // vendor/rector/rector/bin/rector
__DIR__ . '/../../../../../vendor',
];
/**
* @var bool
*/
private $areStubsLoaded = \false;
/**
* @see https://github.com/phpstan/phpstan/issues/4541#issuecomment-779434916
*
* Point possible vendor locations by use the __DIR__ as start to locate
* @see https://github.com/rectorphp/rector/pull/5581 that may not detected in https://getrector.org/ which uses docker to run
*/
public function loadStubs() : void
{
if ($this->areStubsLoaded) {
return;
}
foreach (self::VENDOR_PATHS as $vendorPath) {
$vendorPath = \realpath($vendorPath);
if ($vendorPath === \false) {
continue;
}
foreach (self::STUBS as $stub) {
$path = $this->getStubPath($vendorPath, $stub);
if ($path === null) {
continue 2;
}
require_once $path;
}
$this->areStubsLoaded = \true;
// already loaded? stop loop
break;
}
}
private function getStubPath(string $vendorPath, string $stub) : ?string
{
$path = \sprintf('phar://%s/phpstan/phpstan/phpstan.phar/stubs/runtime/%s', $vendorPath, $stub);
$isExists = \file_exists($path);
if ($isExists) {
return $path;
}
return null;
}
}

View File

@ -1,6 +1,6 @@
<?php
if (! interface_exists('UnitEnum')) {
if (PHP_VERSION_ID < 80100 && ! interface_exists('UnitEnum', false)) {
/**
* @since 8.1
*/
@ -13,7 +13,7 @@ if (! interface_exists('UnitEnum')) {
}
}
if (! interface_exists('BackedEnum')) {
if (PHP_VERSION_ID < 80100 && ! interface_exists('BackedEnum', false)) {
/**
* @since 8.1
*/

View File

@ -0,0 +1,80 @@
<?php
if (PHP_VERSION_ID < 80000 && ! class_exists('ReflectionUnionType', false)) {
class ReflectionUnionType extends ReflectionType
{
/** @return ReflectionType[] */
public function getTypes()
{
return [];
}
}
}
if (\PHP_VERSION_ID < 80000 && ! class_exists('Attribute', false)) {
#[Attribute(Attribute::TARGET_CLASS)]
class Attribute
{
/** @var int */
public $flags;
/**
* Marks that attribute declaration is allowed only in classes.
*/
const TARGET_CLASS = 1;
/**
* Marks that attribute declaration is allowed only in functions.
*/
const TARGET_FUNCTION = 1 << 1;
/**
* Marks that attribute declaration is allowed only in class methods.
*/
const TARGET_METHOD = 1 << 2;
/**
* Marks that attribute declaration is allowed only in class properties.
*/
const TARGET_PROPERTY = 1 << 3;
/**
* Marks that attribute declaration is allowed only in class constants.
*/
const TARGET_CLASS_CONSTANT = 1 << 4;
/**
* Marks that attribute declaration is allowed only in function or method parameters.
*/
const TARGET_PARAMETER = 1 << 5;
/**
* Marks that attribute declaration is allowed anywhere.
*/
const TARGET_ALL = (1 << 6) - 1;
/**
* Notes that an attribute declaration in the same place is
* allowed multiple times.
*/
const IS_REPEATABLE = 1 << 6;
/**
* @param int $flags A value in the form of a bitmask indicating the places
* where attributes can be defined.
*/
public function __construct($flags = self::TARGET_ALL)
{
$this->flags = $flags;
}
}
}
if (\PHP_VERSION_ID < 80100 && ! class_exists('ReturnTypeWillChange', false)) {
#[Attribute(Attribute::TARGET_METHOD)]
final class ReturnTypeWillChange
{
}
}

2
vendor/autoload.php vendored
View File

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

View File

@ -1781,7 +1781,6 @@ return array(
'Rector\\Core\\StaticReflection\\DynamicSourceLocatorDecorator' => $baseDir . '/src/StaticReflection/DynamicSourceLocatorDecorator.php',
'Rector\\Core\\StaticReflection\\SourceLocator\\ParentAttributeSourceLocator' => $baseDir . '/src/StaticReflection/SourceLocator/ParentAttributeSourceLocator.php',
'Rector\\Core\\StaticReflection\\SourceLocator\\RenamedClassesSourceLocator' => $baseDir . '/src/StaticReflection/SourceLocator/RenamedClassesSourceLocator.php',
'Rector\\Core\\Stubs\\PHPStanStubLoader' => $baseDir . '/src/Stubs/PHPStanStubLoader.php',
'Rector\\Core\\Template\\DefaultResolver' => $baseDir . '/src/Template/DefaultResolver.php',
'Rector\\Core\\Util\\MemoryLimiter' => $baseDir . '/src/Util/MemoryLimiter.php',
'Rector\\Core\\Util\\PhpVersionFactory' => $baseDir . '/src/Util/PhpVersionFactory.php',

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit408b7589446e352802303607cb19c324
class ComposerAutoloaderInit75bc346b664248118129de1b6b216239
{
private static $loader;
@ -22,19 +22,19 @@ class ComposerAutoloaderInit408b7589446e352802303607cb19c324
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit408b7589446e352802303607cb19c324', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit75bc346b664248118129de1b6b216239', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit408b7589446e352802303607cb19c324', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit75bc346b664248118129de1b6b216239', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit408b7589446e352802303607cb19c324::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit75bc346b664248118129de1b6b216239::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$includeFiles = \Composer\Autoload\ComposerStaticInit408b7589446e352802303607cb19c324::$files;
$includeFiles = \Composer\Autoload\ComposerStaticInit75bc346b664248118129de1b6b216239::$files;
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire408b7589446e352802303607cb19c324($fileIdentifier, $file);
composerRequire75bc346b664248118129de1b6b216239($fileIdentifier, $file);
}
return $loader;
@ -46,7 +46,7 @@ class ComposerAutoloaderInit408b7589446e352802303607cb19c324
* @param string $file
* @return void
*/
function composerRequire408b7589446e352802303607cb19c324($fileIdentifier, $file)
function composerRequire75bc346b664248118129de1b6b216239($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 ComposerStaticInit408b7589446e352802303607cb19c324
class ComposerStaticInit75bc346b664248118129de1b6b216239
{
public static $files = array (
'320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php',
@ -2150,7 +2150,6 @@ class ComposerStaticInit408b7589446e352802303607cb19c324
'Rector\\Core\\StaticReflection\\DynamicSourceLocatorDecorator' => __DIR__ . '/../..' . '/src/StaticReflection/DynamicSourceLocatorDecorator.php',
'Rector\\Core\\StaticReflection\\SourceLocator\\ParentAttributeSourceLocator' => __DIR__ . '/../..' . '/src/StaticReflection/SourceLocator/ParentAttributeSourceLocator.php',
'Rector\\Core\\StaticReflection\\SourceLocator\\RenamedClassesSourceLocator' => __DIR__ . '/../..' . '/src/StaticReflection/SourceLocator/RenamedClassesSourceLocator.php',
'Rector\\Core\\Stubs\\PHPStanStubLoader' => __DIR__ . '/../..' . '/src/Stubs/PHPStanStubLoader.php',
'Rector\\Core\\Template\\DefaultResolver' => __DIR__ . '/../..' . '/src/Template/DefaultResolver.php',
'Rector\\Core\\Util\\MemoryLimiter' => __DIR__ . '/../..' . '/src/Util/MemoryLimiter.php',
'Rector\\Core\\Util\\PhpVersionFactory' => __DIR__ . '/../..' . '/src/Util/PhpVersionFactory.php',
@ -3883,9 +3882,9 @@ class ComposerStaticInit408b7589446e352802303607cb19c324
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit408b7589446e352802303607cb19c324::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit408b7589446e352802303607cb19c324::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit408b7589446e352802303607cb19c324::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit75bc346b664248118129de1b6b216239::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit75bc346b664248118129de1b6b216239::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit75bc346b664248118129de1b6b216239::$classMap;
}, null, ClassLoader::class);
}

View File

@ -9,8 +9,8 @@ $loader = require_once __DIR__.'/autoload.php';
if (!class_exists('AutoloadIncluder', false) && !interface_exists('AutoloadIncluder', false) && !trait_exists('AutoloadIncluder', false)) {
spl_autoload_call('RectorPrefix20220507\AutoloadIncluder');
}
if (!class_exists('ComposerAutoloaderInit408b7589446e352802303607cb19c324', false) && !interface_exists('ComposerAutoloaderInit408b7589446e352802303607cb19c324', false) && !trait_exists('ComposerAutoloaderInit408b7589446e352802303607cb19c324', false)) {
spl_autoload_call('RectorPrefix20220507\ComposerAutoloaderInit408b7589446e352802303607cb19c324');
if (!class_exists('ComposerAutoloaderInit75bc346b664248118129de1b6b216239', false) && !interface_exists('ComposerAutoloaderInit75bc346b664248118129de1b6b216239', false) && !trait_exists('ComposerAutoloaderInit75bc346b664248118129de1b6b216239', false)) {
spl_autoload_call('RectorPrefix20220507\ComposerAutoloaderInit75bc346b664248118129de1b6b216239');
}
if (!class_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !interface_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !trait_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false)) {
spl_autoload_call('RectorPrefix20220507\Helmich\TypoScriptParser\Parser\AST\Statement');
@ -59,9 +59,9 @@ if (!function_exists('print_node')) {
return \RectorPrefix20220507\print_node(...func_get_args());
}
}
if (!function_exists('composerRequire408b7589446e352802303607cb19c324')) {
function composerRequire408b7589446e352802303607cb19c324() {
return \RectorPrefix20220507\composerRequire408b7589446e352802303607cb19c324(...func_get_args());
if (!function_exists('composerRequire75bc346b664248118129de1b6b216239')) {
function composerRequire75bc346b664248118129de1b6b216239() {
return \RectorPrefix20220507\composerRequire75bc346b664248118129de1b6b216239(...func_get_args());
}
}
if (!function_exists('scanPath')) {