Skip to content

Commit

Permalink
[TypeDeclaration] Skip ArrayDimFetch by return array doc on AddMethod…
Browse files Browse the repository at this point in the history
…CallBasedStrictParamTypeRector (#5058)

* [TypeDeclaration] Skip ArrayDimFetch by return array doc on AddMethodCallBasedStrictParamTypeRector

* Fixed 🎉

* clean up
  • Loading branch information
samsonasik committed Sep 21, 2023
1 parent 69055b5 commit 9f88b63
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/NodeTypeResolver/NodeTypeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ public function getNativeType(Expr $expr): Type
* if (!empty($parts['host'])) { }
*/
$variableType = $scope->getNativeType($expr->var);
if (! $variableType instanceof ArrayType || ! $variableType->getItemType() instanceof MixedType) {
if (! $variableType instanceof MixedType && (! $variableType instanceof ArrayType || ! $variableType->getItemType() instanceof MixedType)) {
$type = $scope->getType($expr);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\AddMethodCallBasedStrictParamTypeRector\Fixture;

final class SkipReturnArrayDoc
{
/**
* @return array<string, string>
*/
private function run()
{
}

private function execute($data)
{
}

public function runData()
{
$values = $this->run();
$this->execute($values['data']);
}
}

0 comments on commit 9f88b63

Please sign in to comment.