Skip to content

Commit

Permalink
add union alias test
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Nov 5, 2021
1 parent cf51620 commit 54a25e0
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

declare(strict_types=1);

namespace Rector\Tests\NameImporting\NodeAnalyzer\UseAnalyzer\Fixture;

use PhpParser\Node\Scalar\String_;
use PhpParser\Node\UnionType as PhpParserUnionType;

final class UnionAliasImports
{
public function param(String_ | PhpParserUnionType $node)
{
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use PhpParser\Node\Identifier;
use PhpParser\Node\Name;
use PhpParser\Node\Name\FullyQualified;
use PhpParser\Node\Scalar\String_;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\UseUse;
use Rector\NameImporting\NodeAnalyzer\UseAnalyzer;
Expand Down Expand Up @@ -95,5 +96,21 @@ public function provideData(): Iterator
];

yield [__DIR__ . '/Fixture/use_import.php.inc', 'SomeClass', 0, new Identifier('SomeClass'), Class_::class];

yield [
__DIR__ . '/Fixture/union_alias_imports.php.inc',
'String_',
0,
new FullyQualified(String_::class),
Node\UnionType::class,
];

yield [
__DIR__ . '/Fixture/union_alias_imports.php.inc',
'PhpParserUnionType',
0,
new Identifier('PhpParserUnionType'),
UseUse::class,
];
}
}

0 comments on commit 54a25e0

Please sign in to comment.