| Subject |
Details |
| Rector version |
Rector dev-master@870e6e7 |
| PHP version |
7.2.12 |
| Full Command |
..\vendor\bin\rector.bat process --dry-run --rule=Rector\TypeDeclaration\Rector\FunctionLike\ReturnTypeDeclarationRector |
Current Behaviour
[applying] Rector\TypeDeclaration\Rector\FunctionLike\ReturnTypeDeclarationRector
PHP Fatal error: Uncaught Rector\Exception\NotImplementedException: Rector\NodeTypeResolver\StaticTypeMapper::mapPHPStanTypeToPhpParserNode for PHPStan\Type\IntersectionType in vendor\rector\rector\packages\NodeTypeResolver\src\StaticTypeMapper.php:288
Stack trace:
#0 vendor\rector\rector\packages\TypeDeclaration\src\Rector\FunctionLike\ReturnTypeDeclarationRector.php(189): Rector\NodeTypeResolver\StaticTypeMapper->mapPHPStanTypeToPhpParserNode(Object(PHPStan\Type\IntersectionType))
#1 vendor\rector\rector\packages\TypeDeclaration\src\Rector\FunctionLike\ReturnTypeDeclarationRector.php(120): Rector\TypeDeclaration\Rector\FunctionLike\ReturnTypeDeclarationRector->isReturnTypeAlreadyAdded(Object(PhpParser\Node\Stmt\ClassMethod), Object(PHPStan\Type\IntersectionType))
#2 vendor\rector\rector\src\Rector\AbstractRector.php(116): Rector\TypeDeclaration\Rector in vendor\rector\rector\packages\NodeTypeResolver\src\StaticTypeMapper.php on line 288
Fatal error: Uncaught Rector\Exception\NotImplementedException: Rector\NodeTypeResolver\StaticTypeMapper::mapPHPStanTypeToPhpParserNode for PHPStan\Type\IntersectionType in vendor\rector\rector\packages\NodeTypeResolver\src\StaticTypeMapper.php:288
Stack trace:
#0 vendor\rector\rector\packages\TypeDeclaration\src\Rector\FunctionLike\ReturnTypeDeclarationRector.php(189): Rector\NodeTypeResolver\StaticTypeMapper->mapPHPStanTypeToPhpParserNode(Object(PHPStan\Type\IntersectionType))
#1 vendor\rector\rector\packages\TypeDeclaration\src\Rector\FunctionLike\ReturnTypeDeclarationRector.php(120): Rector\TypeDeclaration\Rector\FunctionLike\ReturnTypeDeclarationRector->isReturnTypeAlreadyAdded(Object(PhpParser\Node\Stmt\ClassMethod), Object(PHPStan\Type\IntersectionType))
#2 vendor\rector\rector\src\Rector\AbstractRector.php(116): Rector\TypeDeclaration\Rector in vendor\rector\rector\packages\NodeTypeResolver\src\StaticTypeMapper.php on line 288
Minimal PHP Code Causing Issue
<?php
use Doctrine\Common\Collections\Collection;
class Topic
{
/**
* @var Collection|Lesson[]
*/
protected $lessons;
/**
* @return Lesson[]
*/
public function getLessons() : Collection
{
return $this->lessons;
}
}
Basically, this is a simplified Doctrine Entity with a Collection. The getter says it returns the Collection, and the parameter type hint is an Intersection of the Collection type, and the array syntax of what the Collection contains.
Removing either the getter or the @var annotation makes the error not appear.
Expected Behaviour
No error? 😃
Current Behaviour
Minimal PHP Code Causing Issue
Basically, this is a simplified Doctrine Entity with a Collection. The getter says it returns the Collection, and the parameter type hint is an Intersection of the Collection type, and the array syntax of what the Collection contains.
Removing either the getter or the @var annotation makes the error not appear.
Expected Behaviour
No error? 😃