mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-10 05:02:23 +00:00
Updated Rector to commit 3fe07aa6a1
3fe07aa6a1
[Experiment][Naming] Keep GroupUse Stmt on UseImportsResolver::resolveForNode() (#2349)
This commit is contained in:
parent
291f513fb2
commit
a2cadae414
|
@ -5,6 +5,7 @@ namespace Rector\BetterPhpDocParser\PhpDocParser;
|
|||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Identifier;
|
||||
use PhpParser\Node\Stmt\GroupUse;
|
||||
use PhpParser\Node\Stmt\Use_;
|
||||
use PHPStan\Analyser\Scope;
|
||||
use PHPStan\Reflection\ReflectionProvider;
|
||||
|
@ -54,7 +55,7 @@ final class ClassAnnotationMatcher
|
|||
return $fullyQualifiedClass;
|
||||
}
|
||||
/**
|
||||
* @param Use_[] $uses
|
||||
* @param Use_[]|GroupUse[] $uses
|
||||
*/
|
||||
private function resolveFullyQualifiedClass(array $uses, \PhpParser\Node $node, string $tag) : string
|
||||
{
|
||||
|
@ -74,26 +75,21 @@ final class ClassAnnotationMatcher
|
|||
return $this->useImportNameMatcher->matchNameWithUses($tag, $uses) ?? $tag;
|
||||
}
|
||||
/**
|
||||
* @param Use_[] $uses
|
||||
* @param Use_[]|GroupUse[] $uses
|
||||
*/
|
||||
private function resolveAsAliased(array $uses, string $tag) : string
|
||||
{
|
||||
foreach ($uses as $use) {
|
||||
$prefix = $use instanceof \PhpParser\Node\Stmt\GroupUse ? $use->prefix . '\\' : '';
|
||||
$useUses = $use->uses;
|
||||
// skip group uses or empty
|
||||
if (\count($useUses) !== 1) {
|
||||
continue;
|
||||
}
|
||||
// uses already removed
|
||||
if (!isset($useUses[0])) {
|
||||
continue;
|
||||
}
|
||||
if (!$useUses[0]->alias instanceof \PhpParser\Node\Identifier) {
|
||||
continue;
|
||||
}
|
||||
$alias = $useUses[0]->alias;
|
||||
if ($alias->toString() === $tag) {
|
||||
return $useUses[0]->name->toString();
|
||||
foreach ($useUses as $useUse) {
|
||||
if (!$useUse->alias instanceof \PhpParser\Node\Identifier) {
|
||||
continue;
|
||||
}
|
||||
$alias = $useUse->alias;
|
||||
if ($alias->toString() === $tag) {
|
||||
return $prefix . $useUse->name->toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this->useImportNameMatcher->matchNameWithUses($tag, $uses) ?? $tag;
|
||||
|
|
|
@ -4,6 +4,7 @@ declare (strict_types=1);
|
|||
namespace Rector\PostRector\Collector;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Stmt\GroupUse;
|
||||
use Rector\Core\Provider\CurrentFileProvider;
|
||||
use Rector\Core\ValueObject\Application\File;
|
||||
use Rector\Naming\Naming\UseImportsResolver;
|
||||
|
@ -64,11 +65,12 @@ final class UseNodesToAddCollector implements \Rector\PostRector\Contract\Collec
|
|||
$objectTypes = $this->useImportTypesInFilePath[$filePath] ?? [];
|
||||
$uses = $this->useImportsResolver->resolveForNode($node);
|
||||
foreach ($uses as $use) {
|
||||
$prefix = $use instanceof \PhpParser\Node\Stmt\GroupUse ? $use->prefix . '\\' : '';
|
||||
foreach ($use->uses as $useUse) {
|
||||
if ($useUse->alias !== null) {
|
||||
$objectTypes[] = new \Rector\StaticTypeMapper\ValueObject\Type\AliasedObjectType($useUse->alias->toString(), (string) $useUse->name);
|
||||
$objectTypes[] = new \Rector\StaticTypeMapper\ValueObject\Type\AliasedObjectType($useUse->alias->toString(), $prefix . $useUse->name);
|
||||
} else {
|
||||
$objectTypes[] = new \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType((string) $useUse->name);
|
||||
$objectTypes[] = new \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType($prefix . $useUse->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace Rector\StaticTypeMapper\Naming;
|
|||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Stmt\ClassLike;
|
||||
use PhpParser\Node\Stmt\GroupUse;
|
||||
use PhpParser\Node\Stmt\Use_;
|
||||
use PhpParser\Node\Stmt\UseUse;
|
||||
use PHPStan\Analyser\NameScope;
|
||||
|
@ -71,19 +72,20 @@ final class NameScopeFactory
|
|||
return new \PHPStan\Analyser\NameScope($nameScope->getNamespace(), $nameScope->getUses(), $nameScope->getClassName(), null, $templateTypeMap);
|
||||
}
|
||||
/**
|
||||
* @param Use_[] $useNodes
|
||||
* @param Use_[]|GroupUse[] $useNodes
|
||||
* @return array<string, string>
|
||||
*/
|
||||
private function resolveUseNamesByAlias(array $useNodes) : array
|
||||
{
|
||||
$useNamesByAlias = [];
|
||||
foreach ($useNodes as $useNode) {
|
||||
$prefix = $useNode instanceof \PhpParser\Node\Stmt\GroupUse ? $useNode->prefix . '\\' : '';
|
||||
foreach ($useNode->uses as $useUse) {
|
||||
/** @var UseUse $useUse */
|
||||
$aliasName = $useUse->getAlias()->name;
|
||||
// uses must be lowercase, as PHPStan lowercases it
|
||||
$lowercasedAliasName = \strtolower($aliasName);
|
||||
$useNamesByAlias[$lowercasedAliasName] = $useUse->name->toString();
|
||||
$useNamesByAlias[$lowercasedAliasName] = $prefix . $useUse->name->toString();
|
||||
}
|
||||
}
|
||||
return $useNamesByAlias;
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace Rector\CodingStyle\NodeAnalyzer;
|
|||
|
||||
use RectorPrefix20220522\Nette\Utils\Strings;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PhpParser\Node\Stmt\GroupUse;
|
||||
use PhpParser\Node\Stmt\Use_;
|
||||
use PhpParser\Node\Stmt\UseUse;
|
||||
use Rector\Core\PhpParser\Node\BetterNodeFinder;
|
||||
|
@ -37,30 +38,31 @@ final class UseImportNameMatcher
|
|||
return $this->matchNameWithUses($tag, $uses);
|
||||
}
|
||||
/**
|
||||
* @param Use_[] $uses
|
||||
* @param Use_[]|GroupUse[] $uses
|
||||
*/
|
||||
public function matchNameWithUses(string $tag, array $uses) : ?string
|
||||
{
|
||||
foreach ($uses as $use) {
|
||||
$prefix = $use instanceof \PhpParser\Node\Stmt\GroupUse ? $use->prefix . '\\' : '';
|
||||
foreach ($use->uses as $useUse) {
|
||||
if (!$this->isUseMatchingName($tag, $useUse)) {
|
||||
continue;
|
||||
}
|
||||
return $this->resolveName($tag, $useUse);
|
||||
return $this->resolveName($prefix, $tag, $useUse);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public function resolveName(string $tag, \PhpParser\Node\Stmt\UseUse $useUse) : string
|
||||
public function resolveName(string $prefix, string $tag, \PhpParser\Node\Stmt\UseUse $useUse) : string
|
||||
{
|
||||
if ($useUse->alias === null) {
|
||||
return $useUse->name->toString();
|
||||
return $prefix . $useUse->name->toString();
|
||||
}
|
||||
$unaliasedShortClass = \RectorPrefix20220522\Nette\Utils\Strings::substring($tag, \RectorPrefix20220522\Nette\Utils\Strings::length($useUse->alias->toString()));
|
||||
if (\strncmp($unaliasedShortClass, '\\', \strlen('\\')) === 0) {
|
||||
return $useUse->name . $unaliasedShortClass;
|
||||
return $prefix . $useUse->name . $unaliasedShortClass;
|
||||
}
|
||||
return $useUse->name . '\\' . $unaliasedShortClass;
|
||||
return $prefix . $useUse->name . '\\' . $unaliasedShortClass;
|
||||
}
|
||||
private function isUseMatchingName(string $tag, \PhpParser\Node\Stmt\UseUse $useUse) : bool
|
||||
{
|
||||
|
|
|
@ -8,6 +8,7 @@ use PhpParser\Node\Expr\ConstFetch;
|
|||
use PhpParser\Node\Expr\FuncCall;
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Name\FullyQualified;
|
||||
use PhpParser\Node\Stmt\GroupUse;
|
||||
use PhpParser\Node\Stmt\Use_;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Naming\Naming\UseImportsResolver;
|
||||
|
@ -88,7 +89,7 @@ CODE_SAMPLE
|
|||
return \strncmp($name, '\\', \strlen('\\')) === 0;
|
||||
}
|
||||
/**
|
||||
* @param Use_[] $useNodes
|
||||
* @param Use_[]|GroupUse[] $useNodes
|
||||
* @param \PhpParser\Node\Expr\ConstFetch|\PhpParser\Node\Expr\FuncCall $node
|
||||
*/
|
||||
private function getFullyQualifiedName(array $useNodes, $node) : ?string
|
||||
|
@ -99,19 +100,27 @@ CODE_SAMPLE
|
|||
$name = $node->name->toLowerString();
|
||||
$typeFilter = $node instanceof \PhpParser\Node\Expr\ConstFetch ? \PhpParser\Node\Stmt\Use_::TYPE_CONSTANT : \PhpParser\Node\Stmt\Use_::TYPE_FUNCTION;
|
||||
foreach ($useNodes as $useNode) {
|
||||
$prefix = $this->resolvePrefix($useNode);
|
||||
if ($useNode->type !== $typeFilter) {
|
||||
continue;
|
||||
}
|
||||
foreach ($useNode->uses as $useUse) {
|
||||
if ($name === $useUse->name->toLowerString()) {
|
||||
return $useUse->name->toString();
|
||||
if ($name === $prefix . $useUse->name->toLowerString()) {
|
||||
return $prefix . $useUse->name->toString();
|
||||
}
|
||||
$alias = $useUse->getAlias();
|
||||
if ($name === $alias->toLowerString()) {
|
||||
return $useUse->name->toString();
|
||||
return $prefix . $useUse->name->toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* @param \PhpParser\Node\Stmt\Use_|\PhpParser\Node\Stmt\GroupUse $useNode
|
||||
*/
|
||||
private function resolvePrefix($useNode) : string
|
||||
{
|
||||
return $useNode instanceof \PhpParser\Node\Stmt\GroupUse ? $useNode->prefix . '\\' : '';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,22 +5,16 @@ namespace Rector\Naming\Naming;
|
|||
|
||||
use PhpParser\Node\Identifier;
|
||||
use PhpParser\Node\Name;
|
||||
use Rector\NodeNameResolver\NodeNameResolver;
|
||||
use PhpParser\Node\Stmt\GroupUse;
|
||||
final class AliasNameResolver
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\NodeNameResolver\NodeNameResolver
|
||||
*/
|
||||
private $nodeNameResolver;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Naming\Naming\UseImportsResolver
|
||||
*/
|
||||
private $useImportsResolver;
|
||||
public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Naming\Naming\UseImportsResolver $useImportsResolver)
|
||||
public function __construct(\Rector\Naming\Naming\UseImportsResolver $useImportsResolver)
|
||||
{
|
||||
$this->nodeNameResolver = $nodeNameResolver;
|
||||
$this->useImportsResolver = $useImportsResolver;
|
||||
}
|
||||
public function resolveByName(\PhpParser\Node\Name $name) : ?string
|
||||
|
@ -28,21 +22,18 @@ final class AliasNameResolver
|
|||
$uses = $this->useImportsResolver->resolveForNode($name);
|
||||
$nameString = $name->toString();
|
||||
foreach ($uses as $use) {
|
||||
$prefix = $use instanceof \PhpParser\Node\Stmt\GroupUse ? $use->prefix . '\\' : '';
|
||||
$useUses = $use->uses;
|
||||
if (\count($useUses) > 1) {
|
||||
continue;
|
||||
foreach ($useUses as $useUse) {
|
||||
if (!$useUse->alias instanceof \PhpParser\Node\Identifier) {
|
||||
continue;
|
||||
}
|
||||
$name = $prefix . $useUse->name->toString();
|
||||
if ($name !== $nameString) {
|
||||
continue;
|
||||
}
|
||||
return (string) $useUse->getAlias();
|
||||
}
|
||||
if (!isset($useUses[0])) {
|
||||
continue;
|
||||
}
|
||||
$useUse = $useUses[0];
|
||||
if (!$useUse->alias instanceof \PhpParser\Node\Identifier) {
|
||||
continue;
|
||||
}
|
||||
if (!$this->nodeNameResolver->isName($useUse->name, $nameString)) {
|
||||
continue;
|
||||
}
|
||||
return (string) $useUse->getAlias();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -4,11 +4,10 @@ declare (strict_types=1);
|
|||
namespace Rector\Naming\Naming;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PhpParser\Node\Stmt\GroupUse;
|
||||
use PhpParser\Node\Stmt\Namespace_;
|
||||
use PhpParser\Node\Stmt\Use_;
|
||||
use PhpParser\Node\Stmt\UseUse;
|
||||
use Rector\Core\PhpParser\Node\BetterNodeFinder;
|
||||
use Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace;
|
||||
final class UseImportsResolver
|
||||
|
@ -23,7 +22,7 @@ final class UseImportsResolver
|
|||
$this->betterNodeFinder = $betterNodeFinder;
|
||||
}
|
||||
/**
|
||||
* @return Use_[]
|
||||
* @return Use_[]|GroupUse[]
|
||||
*/
|
||||
public function resolveForNode(\PhpParser\Node $node) : array
|
||||
{
|
||||
|
@ -31,20 +30,8 @@ final class UseImportsResolver
|
|||
if (!$namespace instanceof \PhpParser\Node) {
|
||||
return [];
|
||||
}
|
||||
$collectedUses = [];
|
||||
foreach ($namespace->stmts as $stmt) {
|
||||
if ($stmt instanceof \PhpParser\Node\Stmt\Use_) {
|
||||
$collectedUses[] = $stmt;
|
||||
continue;
|
||||
}
|
||||
if ($stmt instanceof \PhpParser\Node\Stmt\GroupUse) {
|
||||
$groupUseUses = [];
|
||||
foreach ($stmt->uses as $useUse) {
|
||||
$groupUseUses[] = new \PhpParser\Node\Stmt\UseUse(new \PhpParser\Node\Name($stmt->prefix . '\\' . $useUse->name), $useUse->alias, $useUse->type, $useUse->getAttributes());
|
||||
}
|
||||
$collectedUses[] = new \PhpParser\Node\Stmt\Use_($groupUseUses, $stmt->type, $stmt->getAttributes());
|
||||
}
|
||||
}
|
||||
return $collectedUses;
|
||||
return \array_filter($namespace->stmts, function (\PhpParser\Node\Stmt $stmt) : bool {
|
||||
return $stmt instanceof \PhpParser\Node\Stmt\Use_ || $stmt instanceof \PhpParser\Node\Stmt\GroupUse;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ use PhpParser\Node\Name;
|
|||
use PhpParser\Node\Name\FullyQualified;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\ClassLike;
|
||||
use PhpParser\Node\Stmt\GroupUse;
|
||||
use PhpParser\Node\Stmt\Namespace_;
|
||||
use PhpParser\Node\Stmt\Use_;
|
||||
use PhpParser\Node\Stmt\UseUse;
|
||||
|
@ -392,9 +393,12 @@ final class ClassRenamer
|
|||
return \true;
|
||||
}
|
||||
foreach ($uses as $use) {
|
||||
if ($this->nodeNameResolver->isName($use, $newName)) {
|
||||
// name already exists
|
||||
return \false;
|
||||
$prefix = $use instanceof \PhpParser\Node\Stmt\GroupUse ? $use->prefix . '\\' : '';
|
||||
foreach ($use->uses as $useUse) {
|
||||
if ($prefix . $useUse->name->toString() === $newName) {
|
||||
// name already exists
|
||||
return \false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return \true;
|
||||
|
|
|
@ -7,6 +7,7 @@ use RectorPrefix20220522\Nette\Utils\Strings;
|
|||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PhpParser\Node\Expr\StaticCall;
|
||||
use PhpParser\Node\Stmt\GroupUse;
|
||||
use PhpParser\Node\Stmt\Use_;
|
||||
use PhpParser\Node\Stmt\UseUse;
|
||||
use PHPStan\Analyser\Scope;
|
||||
|
@ -95,7 +96,7 @@ final class ObjectTypeSpecifier
|
|||
return new \Rector\StaticTypeMapper\ValueObject\Type\NonExistingObjectType($className);
|
||||
}
|
||||
/**
|
||||
* @param Use_[] $uses
|
||||
* @param Use_[]|GroupUse[] $uses
|
||||
*/
|
||||
private function matchAliasedObjectType(\PhpParser\Node $node, \PHPStan\Type\ObjectType $objectType, array $uses) : ?\Rector\StaticTypeMapper\ValueObject\Type\AliasedObjectType
|
||||
{
|
||||
|
@ -105,13 +106,14 @@ final class ObjectTypeSpecifier
|
|||
$className = $objectType->getClassName();
|
||||
$parent = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE);
|
||||
foreach ($uses as $use) {
|
||||
$prefix = $use instanceof \PhpParser\Node\Stmt\GroupUse ? $use->prefix . '\\' : '';
|
||||
foreach ($use->uses as $useUse) {
|
||||
if ($useUse->alias === null) {
|
||||
continue;
|
||||
}
|
||||
$useName = $useUse->name->toString();
|
||||
$useName = $prefix . $useUse->name->toString();
|
||||
$alias = $useUse->alias->toString();
|
||||
$fullyQualifiedName = $useUse->name->toString();
|
||||
$fullyQualifiedName = $prefix . $useUse->name->toString();
|
||||
$processAliasedObject = $this->processAliasedObject($alias, $className, $useName, $parent, $fullyQualifiedName);
|
||||
if ($processAliasedObject instanceof \Rector\StaticTypeMapper\ValueObject\Type\AliasedObjectType) {
|
||||
return $processAliasedObject;
|
||||
|
@ -137,7 +139,7 @@ final class ObjectTypeSpecifier
|
|||
return null;
|
||||
}
|
||||
/**
|
||||
* @param Use_[] $uses
|
||||
* @param Use_[]|GroupUse[] $uses
|
||||
* @return \Rector\StaticTypeMapper\ValueObject\Type\ShortenedObjectType|\Rector\StaticTypeMapper\ValueObject\Type\ShortenedGenericObjectType|null
|
||||
*/
|
||||
private function matchShortenedObjectType(\PHPStan\Type\ObjectType $objectType, array $uses)
|
||||
|
@ -146,15 +148,16 @@ final class ObjectTypeSpecifier
|
|||
return null;
|
||||
}
|
||||
foreach ($uses as $use) {
|
||||
$prefix = $use instanceof \PhpParser\Node\Stmt\GroupUse ? $use->prefix . '\\' : '';
|
||||
foreach ($use->uses as $useUse) {
|
||||
if ($useUse->alias !== null) {
|
||||
continue;
|
||||
}
|
||||
$partialNamespaceObjectType = $this->matchPartialNamespaceObjectType($objectType, $useUse);
|
||||
$partialNamespaceObjectType = $this->matchPartialNamespaceObjectType($prefix, $objectType, $useUse);
|
||||
if ($partialNamespaceObjectType !== null) {
|
||||
return $partialNamespaceObjectType;
|
||||
}
|
||||
$partialNamespaceObjectType = $this->matchClassWithLastUseImportPart($objectType, $useUse);
|
||||
$partialNamespaceObjectType = $this->matchClassWithLastUseImportPart($prefix, $objectType, $useUse);
|
||||
if ($partialNamespaceObjectType instanceof \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType) {
|
||||
// keep Generic items
|
||||
if ($objectType instanceof \PHPStan\Type\Generic\GenericObjectType) {
|
||||
|
@ -169,14 +172,14 @@ final class ObjectTypeSpecifier
|
|||
}
|
||||
return null;
|
||||
}
|
||||
private function matchPartialNamespaceObjectType(\PHPStan\Type\ObjectType $objectType, \PhpParser\Node\Stmt\UseUse $useUse) : ?\Rector\StaticTypeMapper\ValueObject\Type\ShortenedObjectType
|
||||
private function matchPartialNamespaceObjectType(string $prefix, \PHPStan\Type\ObjectType $objectType, \PhpParser\Node\Stmt\UseUse $useUse) : ?\Rector\StaticTypeMapper\ValueObject\Type\ShortenedObjectType
|
||||
{
|
||||
// partial namespace
|
||||
if (\strncmp($objectType->getClassName(), $useUse->name->getLast() . '\\', \strlen($useUse->name->getLast() . '\\')) !== 0) {
|
||||
return null;
|
||||
}
|
||||
$classNameWithoutLastUsePart = \RectorPrefix20220522\Nette\Utils\Strings::after($objectType->getClassName(), '\\', 1);
|
||||
$connectedClassName = $useUse->name->toString() . '\\' . $classNameWithoutLastUsePart;
|
||||
$connectedClassName = $prefix . $useUse->name->toString() . '\\' . $classNameWithoutLastUsePart;
|
||||
if (!$this->reflectionProvider->hasClass($connectedClassName)) {
|
||||
return null;
|
||||
}
|
||||
|
@ -188,17 +191,17 @@ final class ObjectTypeSpecifier
|
|||
/**
|
||||
* @return FullyQualifiedObjectType|ShortenedObjectType|null
|
||||
*/
|
||||
private function matchClassWithLastUseImportPart(\PHPStan\Type\ObjectType $objectType, \PhpParser\Node\Stmt\UseUse $useUse) : ?\PHPStan\Type\ObjectType
|
||||
private function matchClassWithLastUseImportPart(string $prefix, \PHPStan\Type\ObjectType $objectType, \PhpParser\Node\Stmt\UseUse $useUse) : ?\PHPStan\Type\ObjectType
|
||||
{
|
||||
if ($useUse->name->getLast() !== $objectType->getClassName()) {
|
||||
return null;
|
||||
}
|
||||
if (!$this->reflectionProvider->hasClass($useUse->name->toString())) {
|
||||
if (!$this->reflectionProvider->hasClass($prefix . $useUse->name->toString())) {
|
||||
return null;
|
||||
}
|
||||
if ($objectType->getClassName() === $useUse->name->toString()) {
|
||||
if ($objectType->getClassName() === $prefix . $useUse->name->toString()) {
|
||||
return new \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType($objectType->getClassName());
|
||||
}
|
||||
return new \Rector\StaticTypeMapper\ValueObject\Type\ShortenedObjectType($objectType->getClassName(), $useUse->name->toString());
|
||||
return new \Rector\StaticTypeMapper\ValueObject\Type\ShortenedObjectType($objectType->getClassName(), $prefix . $useUse->name->toString());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,11 +16,11 @@ final class VersionResolver
|
|||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = 'f8c204adba7515823ad213f30d541bf87e921177';
|
||||
public const PACKAGE_VERSION = '3fe07aa6a1b368b191cc0ed3df030988ae57bd39';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2022-05-22 19:34:31';
|
||||
public const RELEASE_DATE = '2022-05-22 22:57:59';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
|
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
|
@ -9,4 +9,4 @@ if (PHP_VERSION_ID < 50600) {
|
|||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit59fe6508ef1d2d638f1b1f715bc608ed::getLoader();
|
||||
return ComposerAutoloaderInit3f3eace6c08ea2747322746c977ced25::getLoader();
|
||||
|
|
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 ComposerAutoloaderInit59fe6508ef1d2d638f1b1f715bc608ed
|
||||
class ComposerAutoloaderInit3f3eace6c08ea2747322746c977ced25
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
|
@ -22,19 +22,19 @@ class ComposerAutoloaderInit59fe6508ef1d2d638f1b1f715bc608ed
|
|||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit59fe6508ef1d2d638f1b1f715bc608ed', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit3f3eace6c08ea2747322746c977ced25', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit59fe6508ef1d2d638f1b1f715bc608ed', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit3f3eace6c08ea2747322746c977ced25', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit59fe6508ef1d2d638f1b1f715bc608ed::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit3f3eace6c08ea2747322746c977ced25::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$includeFiles = \Composer\Autoload\ComposerStaticInit59fe6508ef1d2d638f1b1f715bc608ed::$files;
|
||||
$includeFiles = \Composer\Autoload\ComposerStaticInit3f3eace6c08ea2747322746c977ced25::$files;
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequire59fe6508ef1d2d638f1b1f715bc608ed($fileIdentifier, $file);
|
||||
composerRequire3f3eace6c08ea2747322746c977ced25($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
|
@ -46,7 +46,7 @@ class ComposerAutoloaderInit59fe6508ef1d2d638f1b1f715bc608ed
|
|||
* @param string $file
|
||||
* @return void
|
||||
*/
|
||||
function composerRequire59fe6508ef1d2d638f1b1f715bc608ed($fileIdentifier, $file)
|
||||
function composerRequire3f3eace6c08ea2747322746c977ced25($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 ComposerStaticInit59fe6508ef1d2d638f1b1f715bc608ed
|
||||
class ComposerStaticInit3f3eace6c08ea2747322746c977ced25
|
||||
{
|
||||
public static $files = array (
|
||||
'320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php',
|
||||
|
@ -3909,9 +3909,9 @@ class ComposerStaticInit59fe6508ef1d2d638f1b1f715bc608ed
|
|||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit59fe6508ef1d2d638f1b1f715bc608ed::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit59fe6508ef1d2d638f1b1f715bc608ed::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit59fe6508ef1d2d638f1b1f715bc608ed::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit3f3eace6c08ea2747322746c977ced25::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit3f3eace6c08ea2747322746c977ced25::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit3f3eace6c08ea2747322746c977ced25::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
|
8
vendor/composer/installed.json
vendored
8
vendor/composer/installed.json
vendored
|
@ -2786,12 +2786,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/sabbelasichon\/typo3-rector.git",
|
||||
"reference": "7ab2af8604f9f23b043fdb1154803dfd0836aa89"
|
||||
"reference": "a67d7d864cb302d2a3f4163d2ac990f5c6a70bf9"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/sabbelasichon\/typo3-rector\/zipball\/7ab2af8604f9f23b043fdb1154803dfd0836aa89",
|
||||
"reference": "7ab2af8604f9f23b043fdb1154803dfd0836aa89",
|
||||
"url": "https:\/\/api.github.com\/repos\/sabbelasichon\/typo3-rector\/zipball\/a67d7d864cb302d2a3f4163d2ac990f5c6a70bf9",
|
||||
"reference": "a67d7d864cb302d2a3f4163d2ac990f5c6a70bf9",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -2821,7 +2821,7 @@
|
|||
"symplify\/vendor-patches": "^10.2",
|
||||
"tracy\/tracy": "^2.8"
|
||||
},
|
||||
"time": "2022-05-22T14:29:55+00:00",
|
||||
"time": "2022-05-22T18:03:46+00:00",
|
||||
"default-branch": true,
|
||||
"type": "rector-extension",
|
||||
"extra": {
|
||||
|
|
2
vendor/composer/installed.php
vendored
2
vendor/composer/installed.php
vendored
File diff suppressed because one or more lines are too long
|
@ -9,7 +9,7 @@ namespace Rector\RectorInstaller;
|
|||
*/
|
||||
final class GeneratedConfig
|
||||
{
|
||||
public const EXTENSIONS = array('rector/rector-cakephp' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-cakephp', 'relative_install_path' => '../../rector-cakephp', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 43ca394'), 'rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 4a907ed'), 'rector/rector-generator' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-generator', 'relative_install_path' => '../../rector-generator', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 784271e'), 'rector/rector-laravel' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-laravel', 'relative_install_path' => '../../rector-laravel', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 2e0f600'), 'rector/rector-nette' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-nette', 'relative_install_path' => '../../rector-nette', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 5f84d90'), 'rector/rector-phpoffice' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpoffice', 'relative_install_path' => '../../rector-phpoffice', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main e544f2a'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 5a33940'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main f6c3a51'), 'ssch/typo3-rector' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/ssch/typo3-rector', 'relative_install_path' => '../../../ssch/typo3-rector', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 7ab2af8'));
|
||||
public const EXTENSIONS = array('rector/rector-cakephp' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-cakephp', 'relative_install_path' => '../../rector-cakephp', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 43ca394'), 'rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 4a907ed'), 'rector/rector-generator' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-generator', 'relative_install_path' => '../../rector-generator', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 784271e'), 'rector/rector-laravel' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-laravel', 'relative_install_path' => '../../rector-laravel', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 2e0f600'), 'rector/rector-nette' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-nette', 'relative_install_path' => '../../rector-nette', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 5f84d90'), 'rector/rector-phpoffice' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpoffice', 'relative_install_path' => '../../rector-phpoffice', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main e544f2a'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 5a33940'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main f6c3a51'), 'ssch/typo3-rector' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/ssch/typo3-rector', 'relative_install_path' => '../../../ssch/typo3-rector', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main a67d7d8'));
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
|
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('RectorPrefix20220522\AutoloadIncluder');
|
||||
}
|
||||
if (!class_exists('ComposerAutoloaderInit59fe6508ef1d2d638f1b1f715bc608ed', false) && !interface_exists('ComposerAutoloaderInit59fe6508ef1d2d638f1b1f715bc608ed', false) && !trait_exists('ComposerAutoloaderInit59fe6508ef1d2d638f1b1f715bc608ed', false)) {
|
||||
spl_autoload_call('RectorPrefix20220522\ComposerAutoloaderInit59fe6508ef1d2d638f1b1f715bc608ed');
|
||||
if (!class_exists('ComposerAutoloaderInit3f3eace6c08ea2747322746c977ced25', false) && !interface_exists('ComposerAutoloaderInit3f3eace6c08ea2747322746c977ced25', false) && !trait_exists('ComposerAutoloaderInit3f3eace6c08ea2747322746c977ced25', false)) {
|
||||
spl_autoload_call('RectorPrefix20220522\ComposerAutoloaderInit3f3eace6c08ea2747322746c977ced25');
|
||||
}
|
||||
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('RectorPrefix20220522\Helmich\TypoScriptParser\Parser\AST\Statement');
|
||||
|
@ -59,9 +59,9 @@ if (!function_exists('print_node')) {
|
|||
return \RectorPrefix20220522\print_node(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('composerRequire59fe6508ef1d2d638f1b1f715bc608ed')) {
|
||||
function composerRequire59fe6508ef1d2d638f1b1f715bc608ed() {
|
||||
return \RectorPrefix20220522\composerRequire59fe6508ef1d2d638f1b1f715bc608ed(...func_get_args());
|
||||
if (!function_exists('composerRequire3f3eace6c08ea2747322746c977ced25')) {
|
||||
function composerRequire3f3eace6c08ea2747322746c977ced25() {
|
||||
return \RectorPrefix20220522\composerRequire3f3eace6c08ea2747322746c977ced25(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('scanPath')) {
|
||||
|
|
|
@ -45,7 +45,7 @@ CODE_SAMPLE
|
|||
CODE_SAMPLE
|
||||
)]);
|
||||
}
|
||||
public function refactorColumn(\PhpParser\Node\Expr $columnName, \PhpParser\Node\Expr $columnTca) : void
|
||||
protected function refactorColumn(\PhpParser\Node\Expr $columnName, \PhpParser\Node\Expr $columnTca) : void
|
||||
{
|
||||
$configArray = $this->extractSubArrayByKey($columnTca, self::CONFIG);
|
||||
if (!$configArray instanceof \PhpParser\Node\Expr\Array_) {
|
||||
|
|
|
@ -22,6 +22,10 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
|||
final class MigrateRequiredFlagRector extends \Ssch\TYPO3Rector\Rector\Tca\AbstractTcaRector
|
||||
{
|
||||
use TcaHelperTrait;
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private const REQUIRED = 'required';
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
|
@ -60,13 +64,13 @@ CODE_SAMPLE
|
|||
/** @var String_ $evalStringNode */
|
||||
$evalStringNode = $evalArrayItem->value;
|
||||
$value = $evalStringNode->value;
|
||||
if (!\Ssch\TYPO3Rector\Helper\StringUtility::inList($value, 'required')) {
|
||||
if (!\Ssch\TYPO3Rector\Helper\StringUtility::inList($value, self::REQUIRED)) {
|
||||
return;
|
||||
}
|
||||
$evalList = \Ssch\TYPO3Rector\Helper\ArrayUtility::trimExplode(',', $value, \true);
|
||||
// Remove "required" from $evalList
|
||||
$evalList = \array_filter($evalList, static function (string $eval) {
|
||||
return 'required' !== $eval;
|
||||
return self::REQUIRED !== $eval;
|
||||
});
|
||||
if ([] !== $evalList) {
|
||||
// Write back filtered 'eval'
|
||||
|
@ -76,11 +80,11 @@ CODE_SAMPLE
|
|||
$this->removeNode($evalArrayItem);
|
||||
}
|
||||
// If required config exists already, remove it to avoid duplicate array items
|
||||
$requiredItemToRemove = $this->extractArrayItemByKey($configArray, 'required');
|
||||
$requiredItemToRemove = $this->extractArrayItemByKey($configArray, self::REQUIRED);
|
||||
if ($requiredItemToRemove instanceof \PhpParser\Node\Expr\ArrayItem) {
|
||||
$this->removeNode($requiredItemToRemove);
|
||||
}
|
||||
$configArray->items[] = new \PhpParser\Node\Expr\ArrayItem(new \PhpParser\Node\Expr\ConstFetch(new \PhpParser\Node\Name('true')), new \PhpParser\Node\Scalar\String_('required'));
|
||||
$configArray->items[] = new \PhpParser\Node\Expr\ArrayItem(new \PhpParser\Node\Expr\ConstFetch(new \PhpParser\Node\Name('true')), new \PhpParser\Node\Scalar\String_(self::REQUIRED));
|
||||
$this->hasAstBeenChanged = \true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user