mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-17 21:38:22 +01:00
Updated Rector to commit fd4f6d037b20c9b02fa83c98c4fb1524c7374196
fd4f6d037b
[AutoImport] Skip auto import conflict aliased on no namespace (#6266)
This commit is contained in:
parent
334519dc5c
commit
f85eb3d810
@ -9,6 +9,7 @@ use PhpParser\Node\Stmt;
|
||||
use PhpParser\Node\Stmt\Namespace_;
|
||||
use PhpParser\Node\Stmt\Use_;
|
||||
use PhpParser\Node\Stmt\UseUse;
|
||||
use Rector\PhpParser\Node\CustomNode\FileWithoutNamespace;
|
||||
final class AliasUsesResolver
|
||||
{
|
||||
/**
|
||||
@ -26,10 +27,10 @@ final class AliasUsesResolver
|
||||
*/
|
||||
public function resolveFromNode(Node $node, array $stmts) : array
|
||||
{
|
||||
if (!$node instanceof Namespace_) {
|
||||
/** @var Namespace_[] $namespaces */
|
||||
if (!$node instanceof Namespace_ && !$node instanceof FileWithoutNamespace) {
|
||||
/** @var Namespace_[]|FileWithoutNamespace[] $namespaces */
|
||||
$namespaces = \array_filter($stmts, static function (Stmt $stmt) : bool {
|
||||
return $stmt instanceof Namespace_;
|
||||
return $stmt instanceof Namespace_ || $stmt instanceof FileWithoutNamespace;
|
||||
});
|
||||
if (\count($namespaces) !== 1) {
|
||||
return [];
|
||||
|
@ -70,21 +70,14 @@ final class UseImportsResolver
|
||||
if ($newStmts === []) {
|
||||
return null;
|
||||
}
|
||||
/** @var Namespace_[]|FileWithoutNamespace[] $namespaces */
|
||||
$namespaces = \array_filter($newStmts, static function (Stmt $stmt) : bool {
|
||||
return $stmt instanceof Namespace_;
|
||||
return $stmt instanceof Namespace_ || $stmt instanceof FileWithoutNamespace;
|
||||
});
|
||||
// multiple namespaces is not supported
|
||||
if (\count($namespaces) > 1) {
|
||||
if (\count($namespaces) !== 1) {
|
||||
return null;
|
||||
}
|
||||
$currentNamespace = \current($namespaces);
|
||||
if ($currentNamespace instanceof Namespace_) {
|
||||
return $currentNamespace;
|
||||
}
|
||||
$currentStmt = \current($newStmts);
|
||||
if (!$currentStmt instanceof FileWithoutNamespace) {
|
||||
return null;
|
||||
}
|
||||
return $currentStmt;
|
||||
return \current($namespaces);
|
||||
}
|
||||
}
|
||||
|
@ -19,12 +19,12 @@ final class VersionResolver
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '07cfc2754d59ecfcd411e813d9d5fd48def7c035';
|
||||
public const PACKAGE_VERSION = 'fd4f6d037b20c9b02fa83c98c4fb1524c7374196';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2024-08-30 03:16:45';
|
||||
public const RELEASE_DATE = '2024-08-30 13:34:59';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user