mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-10 13:12:23 +00:00
Updated Rector to commit d003424800ab2b06eae432679cda73ee959cbad1
d003424800
From magic array autowire to explicit autowire (#4122)
This commit is contained in:
parent
7e4800f37a
commit
4f94034308
|
@ -10,6 +10,14 @@ use Rector\BetterPhpDocParser\PhpDoc\ArrayItemNode;
|
|||
use Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode;
|
||||
use Rector\BetterPhpDocParser\PhpDoc\StringNode;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\PhpAttribute\AnnotationToAttributeMapper\ArrayAnnotationToAttributeMapper;
|
||||
use Rector\PhpAttribute\AnnotationToAttributeMapper\ArrayItemNodeAnnotationToAttributeMapper;
|
||||
use Rector\PhpAttribute\AnnotationToAttributeMapper\ClassConstFetchAnnotationToAttributeMapper;
|
||||
use Rector\PhpAttribute\AnnotationToAttributeMapper\ConstExprNodeAnnotationToAttributeMapper;
|
||||
use Rector\PhpAttribute\AnnotationToAttributeMapper\CurlyListNodeAnnotationToAttributeMapper;
|
||||
use Rector\PhpAttribute\AnnotationToAttributeMapper\DoctrineAnnotationAnnotationToAttributeMapper;
|
||||
use Rector\PhpAttribute\AnnotationToAttributeMapper\StringAnnotationToAttributeMapper;
|
||||
use Rector\PhpAttribute\AnnotationToAttributeMapper\StringNodeAnnotationToAttributeMapper;
|
||||
use Rector\PhpAttribute\Contract\AnnotationToAttributeMapperInterface;
|
||||
use Rector\PhpAttribute\Enum\DocTagNodeState;
|
||||
/**
|
||||
|
@ -19,15 +27,21 @@ final class AnnotationToAttributeMapper
|
|||
{
|
||||
/**
|
||||
* @var AnnotationToAttributeMapperInterface[]
|
||||
* @readonly
|
||||
*/
|
||||
private $annotationToAttributeMappers;
|
||||
/**
|
||||
* @param AnnotationToAttributeMapperInterface[] $annotationToAttributeMappers
|
||||
*/
|
||||
public function __construct(array $annotationToAttributeMappers)
|
||||
private $annotationToAttributeMappers = [];
|
||||
public function __construct(
|
||||
// private readonly array $annotationToAttributeMappers,
|
||||
ArrayAnnotationToAttributeMapper $arrayAnnotationToAttributeMapper,
|
||||
ArrayItemNodeAnnotationToAttributeMapper $arrayItemNodeAnnotationToAttributeMapper,
|
||||
ClassConstFetchAnnotationToAttributeMapper $classConstFetchAnnotationToAttributeMapper,
|
||||
ConstExprNodeAnnotationToAttributeMapper $constExprNodeAnnotationToAttributeMapper,
|
||||
CurlyListNodeAnnotationToAttributeMapper $curlyListNodeAnnotationToAttributeMapper,
|
||||
DoctrineAnnotationAnnotationToAttributeMapper $doctrineAnnotationAnnotationToAttributeMapper,
|
||||
StringAnnotationToAttributeMapper $stringAnnotationToAttributeMapper,
|
||||
StringNodeAnnotationToAttributeMapper $stringNodeAnnotationToAttributeMapper
|
||||
)
|
||||
{
|
||||
$this->annotationToAttributeMappers = $annotationToAttributeMappers;
|
||||
$this->annotationToAttributeMappers = [$arrayAnnotationToAttributeMapper, $arrayItemNodeAnnotationToAttributeMapper, $classConstFetchAnnotationToAttributeMapper, $constExprNodeAnnotationToAttributeMapper, $curlyListNodeAnnotationToAttributeMapper, $doctrineAnnotationAnnotationToAttributeMapper, $stringAnnotationToAttributeMapper, $stringNodeAnnotationToAttributeMapper];
|
||||
}
|
||||
/**
|
||||
* @return Expr|DocTagNodeState::REMOVE_ARRAY
|
||||
|
|
|
@ -5,12 +5,16 @@ namespace Rector\PostRector\Application;
|
|||
|
||||
use PhpParser\Node\Stmt;
|
||||
use PhpParser\NodeTraverser;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use Rector\Core\Logging\CurrentRectorProvider;
|
||||
use Rector\Core\Provider\CurrentFileProvider;
|
||||
use Rector\Core\ValueObject\Application\File;
|
||||
use Rector\PostRector\Contract\Rector\PostRectorDependencyInterface;
|
||||
use Rector\PostRector\Contract\Rector\PostRectorInterface;
|
||||
use Rector\PostRector\Rector\ClassRenamingPostRector;
|
||||
use Rector\PostRector\Rector\NameImportingPostRector;
|
||||
use Rector\PostRector\Rector\PropertyAddingPostRector;
|
||||
use Rector\PostRector\Rector\UnusedImportRemovingPostRector;
|
||||
use Rector\PostRector\Rector\UseAddingPostRector;
|
||||
use Rector\Skipper\Skipper\Skipper;
|
||||
final class PostFileProcessor
|
||||
{
|
||||
|
@ -33,15 +37,33 @@ final class PostFileProcessor
|
|||
* @var \Rector\Core\Logging\CurrentRectorProvider
|
||||
*/
|
||||
private $currentRectorProvider;
|
||||
/**
|
||||
* @param PostRectorInterface[] $postRectors
|
||||
*/
|
||||
public function __construct(Skipper $skipper, CurrentFileProvider $currentFileProvider, CurrentRectorProvider $currentRectorProvider, array $postRectors)
|
||||
public function __construct(
|
||||
Skipper $skipper,
|
||||
CurrentFileProvider $currentFileProvider,
|
||||
CurrentRectorProvider $currentRectorProvider,
|
||||
// set order here
|
||||
UseAddingPostRector $useAddingPostRector,
|
||||
NameImportingPostRector $nameImportingPostRector,
|
||||
PropertyAddingPostRector $propertyAddingPostRector,
|
||||
ClassRenamingPostRector $classRenamingPostRector,
|
||||
UnusedImportRemovingPostRector $unusedImportRemovingPostRector
|
||||
)
|
||||
{
|
||||
$this->skipper = $skipper;
|
||||
$this->currentFileProvider = $currentFileProvider;
|
||||
$this->currentRectorProvider = $currentRectorProvider;
|
||||
$this->postRectors = $this->sortByPriority($postRectors);
|
||||
$this->postRectors = [
|
||||
// priority: 900
|
||||
$propertyAddingPostRector,
|
||||
// priority: 650
|
||||
$classRenamingPostRector,
|
||||
// priority: 600
|
||||
$nameImportingPostRector,
|
||||
// priority: 500
|
||||
$useAddingPostRector,
|
||||
// priority: 100
|
||||
$unusedImportRemovingPostRector,
|
||||
];
|
||||
}
|
||||
/**
|
||||
* @param Stmt[] $stmts
|
||||
|
@ -60,23 +82,6 @@ final class PostFileProcessor
|
|||
}
|
||||
return $stmts;
|
||||
}
|
||||
/**
|
||||
* @param PostRectorInterface[] $postRectors
|
||||
* @return PostRectorInterface[]
|
||||
*/
|
||||
private function sortByPriority(array $postRectors) : array
|
||||
{
|
||||
$postRectorsByPriority = [];
|
||||
foreach ($postRectors as $postRector) {
|
||||
if (isset($postRectorsByPriority[$postRector->getPriority()])) {
|
||||
$errorMessage = \sprintf('There are multiple post rectors with the same priority: %d. Use different one for your new PostRector', $postRector->getPriority());
|
||||
throw new ShouldNotHappenException($errorMessage);
|
||||
}
|
||||
$postRectorsByPriority[$postRector->getPriority()] = $postRector;
|
||||
}
|
||||
\krsort($postRectorsByPriority);
|
||||
return $postRectorsByPriority;
|
||||
}
|
||||
private function shouldSkipPostRector(PostRectorInterface $postRector) : bool
|
||||
{
|
||||
$file = $this->currentFileProvider->getFile();
|
||||
|
|
|
@ -7,6 +7,9 @@ use PhpParser\Node\Stmt\Class_;
|
|||
use Rector\ChangesReporting\Collector\RectorChangeCollector;
|
||||
use Rector\PostRector\Contract\Collector\NodeCollectorInterface;
|
||||
use Rector\PostRector\ValueObject\PropertyMetadata;
|
||||
/**
|
||||
* @deprecated Use directly in the class
|
||||
*/
|
||||
final class PropertyToAddCollector implements NodeCollectorInterface
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -7,8 +7,4 @@ use PhpParser\NodeVisitor;
|
|||
use Rector\Core\Contract\Rector\RectorInterface;
|
||||
interface PostRectorInterface extends NodeVisitor, RectorInterface
|
||||
{
|
||||
/**
|
||||
* Higher values are executed first
|
||||
*/
|
||||
public function getPriority() : int;
|
||||
}
|
||||
|
|
|
@ -52,11 +52,6 @@ final class ClassRenamingPostRector extends \Rector\PostRector\Rector\AbstractPo
|
|||
$this->rectorConfigProvider = $rectorConfigProvider;
|
||||
$this->useImportsRemover = $useImportsRemover;
|
||||
}
|
||||
public function getPriority() : int
|
||||
{
|
||||
// must be run before name importing, so new names are imported
|
||||
return 650;
|
||||
}
|
||||
/**
|
||||
* @param Stmt[] $nodes
|
||||
* @return Stmt[]
|
||||
|
|
|
@ -108,11 +108,6 @@ final class NameImportingPostRector extends \Rector\PostRector\Rector\AbstractPo
|
|||
}
|
||||
return $node;
|
||||
}
|
||||
public function getPriority() : int
|
||||
{
|
||||
// this must run after NodeRemovingPostRector, sine renamed use imports can block next import
|
||||
return 600;
|
||||
}
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
return new RuleDefinition('Imports fully qualified names', [new CodeSample(<<<'CODE_SAMPLE'
|
||||
|
|
|
@ -36,10 +36,6 @@ final class PropertyAddingPostRector extends \Rector\PostRector\Rector\AbstractP
|
|||
$this->propertyToAddCollector = $propertyToAddCollector;
|
||||
$this->classAnalyzer = $classAnalyzer;
|
||||
}
|
||||
public function getPriority() : int
|
||||
{
|
||||
return 900;
|
||||
}
|
||||
public function enterNode(Node $node) : ?Node
|
||||
{
|
||||
if (!$node instanceof Class_) {
|
||||
|
|
|
@ -74,14 +74,6 @@ final class UnusedImportRemovingPostRector extends \Rector\PostRector\Rector\Abs
|
|||
$node->stmts = \array_values($node->stmts);
|
||||
return $node;
|
||||
}
|
||||
/**
|
||||
* The higher, the later
|
||||
*/
|
||||
public function getPriority() : int
|
||||
{
|
||||
// run this last
|
||||
return 100;
|
||||
}
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
return new RuleDefinition('Removes unused import names', [new CodeSample(<<<'CODE_SAMPLE'
|
||||
|
|
|
@ -82,11 +82,6 @@ final class UseAddingPostRector extends \Rector\PostRector\Rector\AbstractPostRe
|
|||
}
|
||||
return $this->resolveNodesWithImportedUses($nodes, $useImportTypes, $functionUseImportTypes, $namespace);
|
||||
}
|
||||
public function getPriority() : int
|
||||
{
|
||||
// must be after name importing
|
||||
return 500;
|
||||
}
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
return new RuleDefinition('Add unique use imports collected during Rector run', [new CodeSample(<<<'CODE_SAMPLE'
|
||||
|
|
|
@ -19,12 +19,18 @@ use PHPStan\Analyser\MutatingScope;
|
|||
use PHPStan\Analyser\Scope;
|
||||
use PHPStan\Type\ThisType;
|
||||
use PHPStan\Type\Type;
|
||||
use Rector\Naming\AssignVariableNameResolver\NewAssignVariableNameResolver;
|
||||
use Rector\Naming\AssignVariableNameResolver\PropertyFetchAssignVariableNameResolver;
|
||||
use Rector\Naming\Contract\AssignVariableNameResolverInterface;
|
||||
use Rector\NodeNameResolver\NodeNameResolver;
|
||||
use Rector\NodeTypeResolver\NodeTypeResolver;
|
||||
use RectorPrefix202306\Symfony\Component\String\UnicodeString;
|
||||
final class VariableNaming
|
||||
{
|
||||
/**
|
||||
* @var AssignVariableNameResolverInterface[]
|
||||
*/
|
||||
private $assignVariableNameResolvers = [];
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\NodeNameResolver\NodeNameResolver
|
||||
|
@ -35,19 +41,11 @@ final class VariableNaming
|
|||
* @var \Rector\NodeTypeResolver\NodeTypeResolver
|
||||
*/
|
||||
private $nodeTypeResolver;
|
||||
/**
|
||||
* @var AssignVariableNameResolverInterface[]
|
||||
* @readonly
|
||||
*/
|
||||
private $assignVariableNameResolvers;
|
||||
/**
|
||||
* @param AssignVariableNameResolverInterface[] $assignVariableNameResolvers
|
||||
*/
|
||||
public function __construct(NodeNameResolver $nodeNameResolver, NodeTypeResolver $nodeTypeResolver, array $assignVariableNameResolvers)
|
||||
public function __construct(NodeNameResolver $nodeNameResolver, NodeTypeResolver $nodeTypeResolver, PropertyFetchAssignVariableNameResolver $propertyFetchAssignVariableNameResolver, NewAssignVariableNameResolver $newAssignVariableNameResolver)
|
||||
{
|
||||
$this->nodeNameResolver = $nodeNameResolver;
|
||||
$this->nodeTypeResolver = $nodeTypeResolver;
|
||||
$this->assignVariableNameResolvers = $assignVariableNameResolvers;
|
||||
$this->assignVariableNameResolvers = [$propertyFetchAssignVariableNameResolver, $newAssignVariableNameResolver];
|
||||
}
|
||||
/**
|
||||
* @api
|
||||
|
|
|
@ -19,12 +19,12 @@ final class VersionResolver
|
|||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = 'ce31e603b9679098ce089355fc0e68a11a10a9df';
|
||||
public const PACKAGE_VERSION = 'd003424800ab2b06eae432679cda73ee959cbad1';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2023-06-08 21:42:00';
|
||||
public const RELEASE_DATE = '2023-06-08 20:27:24';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
|
|
@ -15,7 +15,7 @@ final class RectorKernel
|
|||
/**
|
||||
* @var string
|
||||
*/
|
||||
private const CACHE_KEY = 'v72';
|
||||
private const CACHE_KEY = 'v73';
|
||||
/**
|
||||
* @var \Symfony\Component\DependencyInjection\ContainerInterface|null
|
||||
*/
|
||||
|
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
|
@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
|
|||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInitc648268ad54f4fdd39cdbdc42d555e9a::getLoader();
|
||||
return ComposerAutoloaderInit74bc75c13626f4b473572213a51b0f9c::getLoader();
|
||||
|
|
10
vendor/composer/autoload_real.php
vendored
10
vendor/composer/autoload_real.php
vendored
|
@ -2,7 +2,7 @@
|
|||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInitc648268ad54f4fdd39cdbdc42d555e9a
|
||||
class ComposerAutoloaderInit74bc75c13626f4b473572213a51b0f9c
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
|
@ -22,17 +22,17 @@ class ComposerAutoloaderInitc648268ad54f4fdd39cdbdc42d555e9a
|
|||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInitc648268ad54f4fdd39cdbdc42d555e9a', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit74bc75c13626f4b473572213a51b0f9c', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitc648268ad54f4fdd39cdbdc42d555e9a', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit74bc75c13626f4b473572213a51b0f9c', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitc648268ad54f4fdd39cdbdc42d555e9a::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit74bc75c13626f4b473572213a51b0f9c::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInitc648268ad54f4fdd39cdbdc42d555e9a::$files;
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit74bc75c13626f4b473572213a51b0f9c::$files;
|
||||
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
|
|
8
vendor/composer/autoload_static.php
vendored
8
vendor/composer/autoload_static.php
vendored
|
@ -4,7 +4,7 @@
|
|||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInitc648268ad54f4fdd39cdbdc42d555e9a
|
||||
class ComposerStaticInit74bc75c13626f4b473572213a51b0f9c
|
||||
{
|
||||
public static $files = array (
|
||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||
|
@ -3154,9 +3154,9 @@ class ComposerStaticInitc648268ad54f4fdd39cdbdc42d555e9a
|
|||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitc648268ad54f4fdd39cdbdc42d555e9a::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitc648268ad54f4fdd39cdbdc42d555e9a::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitc648268ad54f4fdd39cdbdc42d555e9a::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit74bc75c13626f4b473572213a51b0f9c::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit74bc75c13626f4b473572213a51b0f9c::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit74bc75c13626f4b473572213a51b0f9c::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
|
16
vendor/composer/installed.json
vendored
16
vendor/composer/installed.json
vendored
|
@ -504,8 +504,8 @@
|
|||
},
|
||||
{
|
||||
"name": "illuminate\/container",
|
||||
"version": "v10.13.2",
|
||||
"version_normalized": "10.13.2.0",
|
||||
"version": "v10.13.5",
|
||||
"version_normalized": "10.13.5.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/illuminate\/container.git",
|
||||
|
@ -558,17 +558,17 @@
|
|||
},
|
||||
{
|
||||
"name": "illuminate\/contracts",
|
||||
"version": "v10.13.2",
|
||||
"version_normalized": "10.13.2.0",
|
||||
"version": "v10.13.5",
|
||||
"version_normalized": "10.13.5.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/illuminate\/contracts.git",
|
||||
"reference": "8cbe092c4474cb48233b234f722f7d1a5ac1b847"
|
||||
"reference": "93605a5fc27cead6746d84796725c7c0d7d51d62"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/illuminate\/contracts\/zipball\/8cbe092c4474cb48233b234f722f7d1a5ac1b847",
|
||||
"reference": "8cbe092c4474cb48233b234f722f7d1a5ac1b847",
|
||||
"url": "https:\/\/api.github.com\/repos\/illuminate\/contracts\/zipball\/93605a5fc27cead6746d84796725c7c0d7d51d62",
|
||||
"reference": "93605a5fc27cead6746d84796725c7c0d7d51d62",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -576,7 +576,7 @@
|
|||
"psr\/container": "^1.1.1|^2.0.1",
|
||||
"psr\/simple-cache": "^1.0|^2.0|^3.0"
|
||||
},
|
||||
"time": "2023-05-30T21:33:10+00:00",
|
||||
"time": "2023-06-06T15:23:52+00:00",
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
|
|
2
vendor/composer/installed.php
vendored
2
vendor/composer/installed.php
vendored
File diff suppressed because one or more lines are too long
|
@ -15,7 +15,7 @@ interface CastsAttributes
|
|||
* @param \Illuminate\Database\Eloquent\Model $model
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @param array $attributes
|
||||
* @param array<string, mixed> $attributes
|
||||
* @return TGet|null
|
||||
*/
|
||||
public function get(Model $model, string $key, $value, array $attributes);
|
||||
|
@ -25,7 +25,7 @@ interface CastsAttributes
|
|||
* @param \Illuminate\Database\Eloquent\Model $model
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @param array $attributes
|
||||
* @param array<string, mixed> $attributes
|
||||
* @return mixed
|
||||
*/
|
||||
public function set(Model $model, string $key, $value, array $attributes);
|
||||
|
|
Loading…
Reference in New Issue
Block a user