mirror of
https://github.com/rectorphp/rector.git
synced 2024-05-28 23:10:51 +00:00
Updated Rector to commit acabcfc456
acabcfc456
[TypeDeclaration] Do not add return type on parent Closure for deep closure has return type on ReturnTypeFromStrictTypedCallRector (#439)
This commit is contained in:
parent
65a21970aa
commit
cae21ff247
|
@ -9446,6 +9446,7 @@ return static function (ContainerConfigurator $containerConfigurator): void {
|
|||
class SomeClass
|
||||
{
|
||||
+ public function __construct(AnotherClassFactory $anotherClassFactory)
|
||||
+ {c function __construct(AnotherClassFactory $anotherClassFactory)
|
||||
+ {
|
||||
+ $this->anotherClassFactory = $anotherClassFactory;
|
||||
+ }
|
||||
|
|
|
@ -1,145 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Restoration\Rector\New_;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Arg;
|
||||
use PhpParser\Node\Expr\New_;
|
||||
use PhpParser\Node\Name\FullyQualified;
|
||||
use PHPStan\Reflection\ReflectionProvider;
|
||||
use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use ReflectionMethod;
|
||||
use ReflectionNamedType;
|
||||
use ReflectionParameter;
|
||||
use ReflectionType;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
* @see \Rector\Tests\Restoration\Rector\New_\CompleteMissingDependencyInNewRector\CompleteMissingDependencyInNewRectorTest
|
||||
*/
|
||||
final class CompleteMissingDependencyInNewRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface
|
||||
{
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const CLASS_TO_INSTANTIATE_BY_TYPE = 'class_to_instantiate_by_type';
|
||||
/**
|
||||
* @var array<class-string, class-string>
|
||||
*/
|
||||
private $classToInstantiateByType = [];
|
||||
/**
|
||||
* @var \PHPStan\Reflection\ReflectionProvider
|
||||
*/
|
||||
private $reflectionProvider;
|
||||
public function __construct(\PHPStan\Reflection\ReflectionProvider $reflectionProvider)
|
||||
{
|
||||
$this->reflectionProvider = $reflectionProvider;
|
||||
}
|
||||
public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition
|
||||
{
|
||||
return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Complete missing constructor dependency instance by type', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE'
|
||||
final class SomeClass
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
$valueObject = new RandomValueObject();
|
||||
}
|
||||
}
|
||||
|
||||
class RandomValueObject
|
||||
{
|
||||
public function __construct(RandomDependency $randomDependency)
|
||||
{
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
, <<<'CODE_SAMPLE'
|
||||
final class SomeClass
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
$valueObject = new RandomValueObject(new RandomDependency());
|
||||
}
|
||||
}
|
||||
|
||||
class RandomValueObject
|
||||
{
|
||||
public function __construct(RandomDependency $randomDependency)
|
||||
{
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
, [self::CLASS_TO_INSTANTIATE_BY_TYPE => ['RandomDependency' => 'RandomDependency']])]);
|
||||
}
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [\PhpParser\Node\Expr\New_::class];
|
||||
}
|
||||
/**
|
||||
* @param New_ $node
|
||||
*/
|
||||
public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node
|
||||
{
|
||||
if ($this->shouldSkipNew($node)) {
|
||||
return null;
|
||||
}
|
||||
/** @var ReflectionMethod $constructorMethodReflection */
|
||||
$constructorMethodReflection = $this->getNewNodeClassConstructorMethodReflection($node);
|
||||
foreach ($constructorMethodReflection->getParameters() as $position => $reflectionParameter) {
|
||||
// argument is already set
|
||||
if (isset($node->args[$position])) {
|
||||
continue;
|
||||
}
|
||||
$classToInstantiate = $this->resolveClassToInstantiateByParameterReflection($reflectionParameter);
|
||||
if ($classToInstantiate === null) {
|
||||
continue;
|
||||
}
|
||||
$new = new \PhpParser\Node\Expr\New_(new \PhpParser\Node\Name\FullyQualified($classToInstantiate));
|
||||
$node->args[$position] = new \PhpParser\Node\Arg($new);
|
||||
}
|
||||
return $node;
|
||||
}
|
||||
/**
|
||||
* @param array<string, array<class-string, class-string>> $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$this->classToInstantiateByType = $configuration[self::CLASS_TO_INSTANTIATE_BY_TYPE] ?? [];
|
||||
}
|
||||
private function shouldSkipNew(\PhpParser\Node\Expr\New_ $new) : bool
|
||||
{
|
||||
$constructorMethodReflection = $this->getNewNodeClassConstructorMethodReflection($new);
|
||||
if (!$constructorMethodReflection instanceof \ReflectionMethod) {
|
||||
return \true;
|
||||
}
|
||||
return $constructorMethodReflection->getNumberOfRequiredParameters() <= \count($new->args);
|
||||
}
|
||||
private function getNewNodeClassConstructorMethodReflection(\PhpParser\Node\Expr\New_ $new) : ?\ReflectionMethod
|
||||
{
|
||||
$className = $this->getName($new->class);
|
||||
if ($className === null) {
|
||||
return null;
|
||||
}
|
||||
if (!$this->reflectionProvider->hasClass($className)) {
|
||||
return null;
|
||||
}
|
||||
$classReflection = $this->reflectionProvider->getClass($className);
|
||||
$reflectionClass = $classReflection->getNativeReflection();
|
||||
return $reflectionClass->getConstructor();
|
||||
}
|
||||
private function resolveClassToInstantiateByParameterReflection(\ReflectionParameter $reflectionParameter) : ?string
|
||||
{
|
||||
$reflectionType = $reflectionParameter->getType();
|
||||
if (!$reflectionType instanceof \ReflectionType) {
|
||||
return null;
|
||||
}
|
||||
$requiredType = $reflectionType instanceof \ReflectionNamedType ? $reflectionType->getName() : (string) $reflectionType;
|
||||
return $this->classToInstantiateByType[$requiredType] ?? null;
|
||||
}
|
||||
}
|
|
@ -8,6 +8,7 @@ use PhpParser\Node\Expr\Closure;
|
|||
use PhpParser\Node\Expr\FuncCall;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PhpParser\Node\Expr\StaticCall;
|
||||
use PhpParser\Node\FunctionLike;
|
||||
use PhpParser\Node\Identifier;
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Name\FullyQualified;
|
||||
|
@ -93,7 +94,21 @@ CODE_SAMPLE
|
|||
return null;
|
||||
}
|
||||
/** @var Return_[] $returns */
|
||||
$returns = $this->betterNodeFinder->findInstanceOf((array) $node->stmts, \PhpParser\Node\Stmt\Return_::class);
|
||||
$returns = $this->betterNodeFinder->find((array) $node->stmts, function (\PhpParser\Node $n) use($node) {
|
||||
$currentFunctionLike = $this->betterNodeFinder->findParentType($n, \PhpParser\Node\FunctionLike::class);
|
||||
if ($currentFunctionLike === $node) {
|
||||
return $n instanceof \PhpParser\Node\Stmt\Return_;
|
||||
}
|
||||
$currentReturn = $this->betterNodeFinder->findParentType($n, \PhpParser\Node\Stmt\Return_::class);
|
||||
if (!$currentReturn instanceof \PhpParser\Node\Stmt\Return_) {
|
||||
return \false;
|
||||
}
|
||||
$currentFunctionLike = $this->betterNodeFinder->findParentType($currentReturn, \PhpParser\Node\FunctionLike::class);
|
||||
if ($currentFunctionLike !== $node) {
|
||||
return \false;
|
||||
}
|
||||
return $n instanceof \PhpParser\Node\Stmt\Return_;
|
||||
});
|
||||
$returnedStrictTypes = $this->collectStrictReturnTypes($returns);
|
||||
if ($returnedStrictTypes === []) {
|
||||
return null;
|
||||
|
|
|
@ -16,11 +16,11 @@ final class VersionResolver
|
|||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = 'f7ba2752e3c9731621d9b81e535dc7d998c4aa1d';
|
||||
public const PACKAGE_VERSION = 'acabcfc4565c3691eb1f2076db85524edc583a9b';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2021-07-15 01:07:54';
|
||||
public const RELEASE_DATE = '2021-07-15 09:32:46';
|
||||
public static function resolvePackageVersion() : string
|
||||
{
|
||||
$process = new \RectorPrefix20210715\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__);
|
||||
|
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
|
@ -4,4 +4,4 @@
|
|||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit2043d736b2ca689d52e4bedb374f5ad6::getLoader();
|
||||
return ComposerAutoloaderInitc3f7a47dcc1e46bd4612e40ad4cb6787::getLoader();
|
||||
|
|
1
vendor/composer/autoload_classmap.php
vendored
1
vendor/composer/autoload_classmap.php
vendored
|
@ -2897,7 +2897,6 @@ return array(
|
|||
'Rector\\Restoration\\Rector\\ClassMethod\\InferParamFromClassMethodReturnRector' => $baseDir . '/rules/Restoration/Rector/ClassMethod/InferParamFromClassMethodReturnRector.php',
|
||||
'Rector\\Restoration\\Rector\\Class_\\RemoveFinalFromEntityRector' => $baseDir . '/rules/Restoration/Rector/Class_/RemoveFinalFromEntityRector.php',
|
||||
'Rector\\Restoration\\Rector\\Namespace_\\CompleteImportForPartialAnnotationRector' => $baseDir . '/rules/Restoration/Rector/Namespace_/CompleteImportForPartialAnnotationRector.php',
|
||||
'Rector\\Restoration\\Rector\\New_\\CompleteMissingDependencyInNewRector' => $baseDir . '/rules/Restoration/Rector/New_/CompleteMissingDependencyInNewRector.php',
|
||||
'Rector\\Restoration\\Rector\\Property\\MakeTypedPropertyNullableIfCheckedRector' => $baseDir . '/rules/Restoration/Rector/Property/MakeTypedPropertyNullableIfCheckedRector.php',
|
||||
'Rector\\Restoration\\Type\\ConstantReturnToParamTypeConverter' => $baseDir . '/rules/Restoration/Type/ConstantReturnToParamTypeConverter.php',
|
||||
'Rector\\Restoration\\ValueObject\\CompleteImportForPartialAnnotation' => $baseDir . '/rules/Restoration/ValueObject/CompleteImportForPartialAnnotation.php',
|
||||
|
|
14
vendor/composer/autoload_real.php
vendored
14
vendor/composer/autoload_real.php
vendored
|
@ -2,7 +2,7 @@
|
|||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit2043d736b2ca689d52e4bedb374f5ad6
|
||||
class ComposerAutoloaderInitc3f7a47dcc1e46bd4612e40ad4cb6787
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
|
@ -22,15 +22,15 @@ class ComposerAutoloaderInit2043d736b2ca689d52e4bedb374f5ad6
|
|||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit2043d736b2ca689d52e4bedb374f5ad6', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInitc3f7a47dcc1e46bd4612e40ad4cb6787', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit2043d736b2ca689d52e4bedb374f5ad6', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitc3f7a47dcc1e46bd4612e40ad4cb6787', 'loadClassLoader'));
|
||||
|
||||
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
||||
if ($useStaticLoader) {
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit2043d736b2ca689d52e4bedb374f5ad6::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitc3f7a47dcc1e46bd4612e40ad4cb6787::getInitializer($loader));
|
||||
} else {
|
||||
$classMap = require __DIR__ . '/autoload_classmap.php';
|
||||
if ($classMap) {
|
||||
|
@ -42,19 +42,19 @@ class ComposerAutoloaderInit2043d736b2ca689d52e4bedb374f5ad6
|
|||
$loader->register(true);
|
||||
|
||||
if ($useStaticLoader) {
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInit2043d736b2ca689d52e4bedb374f5ad6::$files;
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInitc3f7a47dcc1e46bd4612e40ad4cb6787::$files;
|
||||
} else {
|
||||
$includeFiles = require __DIR__ . '/autoload_files.php';
|
||||
}
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequire2043d736b2ca689d52e4bedb374f5ad6($fileIdentifier, $file);
|
||||
composerRequirec3f7a47dcc1e46bd4612e40ad4cb6787($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
}
|
||||
}
|
||||
|
||||
function composerRequire2043d736b2ca689d52e4bedb374f5ad6($fileIdentifier, $file)
|
||||
function composerRequirec3f7a47dcc1e46bd4612e40ad4cb6787($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
require $file;
|
||||
|
|
9
vendor/composer/autoload_static.php
vendored
9
vendor/composer/autoload_static.php
vendored
|
@ -4,7 +4,7 @@
|
|||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit2043d736b2ca689d52e4bedb374f5ad6
|
||||
class ComposerStaticInitc3f7a47dcc1e46bd4612e40ad4cb6787
|
||||
{
|
||||
public static $files = array (
|
||||
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
|
||||
|
@ -3252,7 +3252,6 @@ class ComposerStaticInit2043d736b2ca689d52e4bedb374f5ad6
|
|||
'Rector\\Restoration\\Rector\\ClassMethod\\InferParamFromClassMethodReturnRector' => __DIR__ . '/../..' . '/rules/Restoration/Rector/ClassMethod/InferParamFromClassMethodReturnRector.php',
|
||||
'Rector\\Restoration\\Rector\\Class_\\RemoveFinalFromEntityRector' => __DIR__ . '/../..' . '/rules/Restoration/Rector/Class_/RemoveFinalFromEntityRector.php',
|
||||
'Rector\\Restoration\\Rector\\Namespace_\\CompleteImportForPartialAnnotationRector' => __DIR__ . '/../..' . '/rules/Restoration/Rector/Namespace_/CompleteImportForPartialAnnotationRector.php',
|
||||
'Rector\\Restoration\\Rector\\New_\\CompleteMissingDependencyInNewRector' => __DIR__ . '/../..' . '/rules/Restoration/Rector/New_/CompleteMissingDependencyInNewRector.php',
|
||||
'Rector\\Restoration\\Rector\\Property\\MakeTypedPropertyNullableIfCheckedRector' => __DIR__ . '/../..' . '/rules/Restoration/Rector/Property/MakeTypedPropertyNullableIfCheckedRector.php',
|
||||
'Rector\\Restoration\\Type\\ConstantReturnToParamTypeConverter' => __DIR__ . '/../..' . '/rules/Restoration/Type/ConstantReturnToParamTypeConverter.php',
|
||||
'Rector\\Restoration\\ValueObject\\CompleteImportForPartialAnnotation' => __DIR__ . '/../..' . '/rules/Restoration/ValueObject/CompleteImportForPartialAnnotation.php',
|
||||
|
@ -3846,9 +3845,9 @@ class ComposerStaticInit2043d736b2ca689d52e4bedb374f5ad6
|
|||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit2043d736b2ca689d52e4bedb374f5ad6::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit2043d736b2ca689d52e4bedb374f5ad6::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit2043d736b2ca689d52e4bedb374f5ad6::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitc3f7a47dcc1e46bd4612e40ad4cb6787::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitc3f7a47dcc1e46bd4612e40ad4cb6787::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitc3f7a47dcc1e46bd4612e40ad4cb6787::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
|
8
vendor/composer/installed.json
vendored
8
vendor/composer/installed.json
vendored
|
@ -1884,12 +1884,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/symfony\/dependency-injection.git",
|
||||
"reference": "64833ac4f2a6dcc5c08fe705e4d1d6e4c38a09f8"
|
||||
"reference": "006f585b01f51188a8b30be06df64d1a489d5dec"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/symfony\/dependency-injection\/zipball\/64833ac4f2a6dcc5c08fe705e4d1d6e4c38a09f8",
|
||||
"reference": "64833ac4f2a6dcc5c08fe705e4d1d6e4c38a09f8",
|
||||
"url": "https:\/\/api.github.com\/repos\/symfony\/dependency-injection\/zipball\/006f585b01f51188a8b30be06df64d1a489d5dec",
|
||||
"reference": "006f585b01f51188a8b30be06df64d1a489d5dec",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -1922,7 +1922,7 @@
|
|||
"symfony\/proxy-manager-bridge": "Generate service proxies to lazy load them",
|
||||
"symfony\/yaml": ""
|
||||
},
|
||||
"time": "2021-07-07T15:10:28+00:00",
|
||||
"time": "2021-07-15T12:19:54+00:00",
|
||||
"default-branch": true,
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
|
|
2
vendor/composer/installed.php
vendored
2
vendor/composer/installed.php
vendored
File diff suppressed because one or more lines are too long
10
vendor/scoper-autoload.php
vendored
10
vendor/scoper-autoload.php
vendored
|
@ -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('RectorPrefix20210715\AutoloadIncluder');
|
||||
}
|
||||
if (!class_exists('ComposerAutoloaderInit2043d736b2ca689d52e4bedb374f5ad6', false) && !interface_exists('ComposerAutoloaderInit2043d736b2ca689d52e4bedb374f5ad6', false) && !trait_exists('ComposerAutoloaderInit2043d736b2ca689d52e4bedb374f5ad6', false)) {
|
||||
spl_autoload_call('RectorPrefix20210715\ComposerAutoloaderInit2043d736b2ca689d52e4bedb374f5ad6');
|
||||
if (!class_exists('ComposerAutoloaderInitc3f7a47dcc1e46bd4612e40ad4cb6787', false) && !interface_exists('ComposerAutoloaderInitc3f7a47dcc1e46bd4612e40ad4cb6787', false) && !trait_exists('ComposerAutoloaderInitc3f7a47dcc1e46bd4612e40ad4cb6787', false)) {
|
||||
spl_autoload_call('RectorPrefix20210715\ComposerAutoloaderInitc3f7a47dcc1e46bd4612e40ad4cb6787');
|
||||
}
|
||||
if (!class_exists('Doctrine\Inflector\Inflector', false) && !interface_exists('Doctrine\Inflector\Inflector', false) && !trait_exists('Doctrine\Inflector\Inflector', false)) {
|
||||
spl_autoload_call('RectorPrefix20210715\Doctrine\Inflector\Inflector');
|
||||
|
@ -3308,9 +3308,9 @@ if (!function_exists('print_node')) {
|
|||
return \RectorPrefix20210715\print_node(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('composerRequire2043d736b2ca689d52e4bedb374f5ad6')) {
|
||||
function composerRequire2043d736b2ca689d52e4bedb374f5ad6() {
|
||||
return \RectorPrefix20210715\composerRequire2043d736b2ca689d52e4bedb374f5ad6(...func_get_args());
|
||||
if (!function_exists('composerRequirec3f7a47dcc1e46bd4612e40ad4cb6787')) {
|
||||
function composerRequirec3f7a47dcc1e46bd4612e40ad4cb6787() {
|
||||
return \RectorPrefix20210715\composerRequirec3f7a47dcc1e46bd4612e40ad4cb6787(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('parseArgs')) {
|
||||
|
|
|
@ -134,6 +134,12 @@ final class CheckTypeDeclarationsPass extends \RectorPrefix20210715\Symfony\Comp
|
|||
}
|
||||
throw new \RectorPrefix20210715\Symfony\Component\DependencyInjection\Exception\InvalidParameterTypeException($this->currentId, $e->getCode(), $parameter);
|
||||
}
|
||||
if ($reflectionType instanceof \RectorPrefix20210715\ReflectionIntersectionType) {
|
||||
foreach ($reflectionType->getTypes() as $t) {
|
||||
$this->checkType($checkedDefinition, $value, $parameter, $envPlaceholderUniquePrefix, $t);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!$reflectionType instanceof \ReflectionNamedType) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@ final class Preloader
|
|||
if (!$t) {
|
||||
return;
|
||||
}
|
||||
foreach ($t instanceof \ReflectionUnionType ? $t->getTypes() : [$t] as $t) {
|
||||
foreach ($t instanceof \ReflectionUnionType || $t instanceof \RectorPrefix20210715\ReflectionIntersectionType ? $t->getTypes() : [$t] as $t) {
|
||||
if (!$t->isBuiltin()) {
|
||||
self::doPreload($t instanceof \ReflectionNamedType ? $t->getName() : $t, $preloaded);
|
||||
}
|
||||
|
|
|
@ -34,18 +34,28 @@ class ProxyHelper
|
|||
return null;
|
||||
}
|
||||
$types = [];
|
||||
foreach ($type instanceof \ReflectionUnionType ? $type->getTypes() : [$type] as $type) {
|
||||
$name = $type instanceof \ReflectionNamedType ? $type->getName() : (string) $type;
|
||||
$glue = '|';
|
||||
if ($type instanceof \ReflectionUnionType) {
|
||||
$reflectionTypes = $type->getTypes();
|
||||
} elseif ($type instanceof \RectorPrefix20210715\ReflectionIntersectionType) {
|
||||
$reflectionTypes = $type->getTypes();
|
||||
$glue = '&';
|
||||
} elseif ($type instanceof \ReflectionNamedType) {
|
||||
$reflectionTypes = [$type];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
foreach ($reflectionTypes as $type) {
|
||||
if ($type->isBuiltin()) {
|
||||
if (!$noBuiltin) {
|
||||
$types[] = $name;
|
||||
$types[] = $type->getName();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
$lcName = \strtolower($name);
|
||||
$lcName = \strtolower($type->getName());
|
||||
$prefix = $noBuiltin ? '' : '\\';
|
||||
if ('self' !== $lcName && 'parent' !== $lcName) {
|
||||
$types[] = '' !== $prefix ? $prefix . $name : $name;
|
||||
$types[] = $prefix . $type->getName();
|
||||
continue;
|
||||
}
|
||||
if (!$r instanceof \ReflectionMethod) {
|
||||
|
@ -57,6 +67,6 @@ class ProxyHelper
|
|||
$types[] = ($parent = $r->getDeclaringClass()->getParentClass()) ? $prefix . $parent->name : null;
|
||||
}
|
||||
}
|
||||
return $types ? \implode('|', $types) : null;
|
||||
return $types ? \implode($glue, $types) : null;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user