Skip to content

Commit f59b593

Browse files
committed
fix
1 parent 23475c6 commit f59b593

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

rules-tests/TypeDeclarationDocblocks/Rector/ClassMethod/DocblockReturnArrayFromDirectArrayInstanceRector/Fixture/return_empty.php.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace Rector\Tests\TypeDeclarationDocblocks\Rector\ClassMethod\DocblockRetur
1919
class ReturnEmpty
2020
{
2121
/**
22-
* @return mixed[]
22+
* @return array<int, mixed>
2323
*/
2424
public function run(): array
2525
{

rules/TypeDeclarationDocblocks/Rector/ClassMethod/DocblockReturnArrayFromDirectArrayInstanceRector.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@ private function createGenericArrayTypeFromConstantArrayType(ConstantArrayType $
152152
{
153153
$genericKeyType = $this->constantToGenericType($constantArrayType->getKeyType());
154154

155+
if ($constantArrayType->getItemType() instanceof \PHPStan\Type\NeverType) {
156+
$genericKeyType = new IntegerType();
157+
}
158+
155159
$itemType = $constantArrayType->getItemType();
156160
if ($itemType instanceof ConstantArrayType) {
157161
$genericItemType = $this->createGenericArrayTypeFromConstantArrayType($itemType);

0 commit comments

Comments
 (0)