mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-20 06:38:46 +01:00
[Type Declaration] Fix unwrapping of multiple union types (#4043)
This commit is contained in:
parent
dffcae0c82
commit
5b4797af85
@ -92,7 +92,7 @@ final class TypeFactory
|
||||
$unwrappedTypes = [];
|
||||
foreach ($types as $key => $type) {
|
||||
if ($type instanceof UnionType) {
|
||||
$unwrappedTypes = $type->getTypes();
|
||||
$unwrappedTypes = array_merge($unwrappedTypes, $type->getTypes());
|
||||
|
||||
unset($types[$key]);
|
||||
}
|
||||
|
@ -19,11 +19,24 @@ final class AddArrayReturnDocTypeRectorTest extends AbstractRectorTestCase
|
||||
$this->doTestFileInfo($fileInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideDataRectorUseCases()
|
||||
*/
|
||||
public function testRectorUseCases(SmartFileInfo $fileInfo): void
|
||||
{
|
||||
$this->doTestFileInfo($fileInfo);
|
||||
}
|
||||
|
||||
public function provideData(): Iterator
|
||||
{
|
||||
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
|
||||
}
|
||||
|
||||
public function provideDataRectorUseCases(): Iterator
|
||||
{
|
||||
return $this->yieldFilesFromDirectory(__DIR__ . '/RectorUseCasesFixture');
|
||||
}
|
||||
|
||||
protected function getRectorClass(): string
|
||||
{
|
||||
return AddArrayReturnDocTypeRector::class;
|
||||
|
@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\TypeDeclaration\Tests\Rector\ClassMethod\AddArrayReturnDocTypeRector\RectorUseCasesFixture;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\FuncCall;
|
||||
use PHPStan\Reflection\FunctionReflection;
|
||||
use PHPStan\Reflection\MethodReflection;
|
||||
|
||||
class CallReflectionResolverFixture
|
||||
{
|
||||
public function resolveCall(Node $node)
|
||||
{
|
||||
if ($node instanceof FuncCall) {
|
||||
return $this->resolveFunctionCall($node);
|
||||
}
|
||||
|
||||
return $this->resolveMethodCall($node);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return FunctionReflection|MethodReflection|null
|
||||
*/
|
||||
private function resolveFunctionCall(FuncCall $funcCall)
|
||||
{
|
||||
}
|
||||
|
||||
private function resolveMethodCall(Node $node): ?MethodReflection
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
-----
|
||||
<?php
|
||||
|
||||
namespace Rector\TypeDeclaration\Tests\Rector\ClassMethod\AddArrayReturnDocTypeRector\RectorUseCasesFixture;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\FuncCall;
|
||||
use PHPStan\Reflection\FunctionReflection;
|
||||
use PHPStan\Reflection\MethodReflection;
|
||||
|
||||
class CallReflectionResolverFixture
|
||||
{
|
||||
/**
|
||||
* @return \PHPStan\Reflection\FunctionReflection|\PHPStan\Reflection\MethodReflection|null
|
||||
*/
|
||||
public function resolveCall(Node $node)
|
||||
{
|
||||
if ($node instanceof FuncCall) {
|
||||
return $this->resolveFunctionCall($node);
|
||||
}
|
||||
|
||||
return $this->resolveMethodCall($node);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return FunctionReflection|MethodReflection|null
|
||||
*/
|
||||
private function resolveFunctionCall(FuncCall $funcCall)
|
||||
{
|
||||
}
|
||||
|
||||
private function resolveMethodCall(Node $node): ?MethodReflection
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
Loading…
x
Reference in New Issue
Block a user