File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change 1010use PhpParser \Node \Identifier ;
1111use PHPStan \Type \ObjectType ;
1212use PHPStan \Type \TypeCombinator ;
13+ use Rector \PHPStan \ScopeFetcher ;
1314use RectorLaravel \AbstractRector ;
1415use Symplify \RuleDocGenerator \ValueObject \CodeSample \CodeSample ;
1516use Symplify \RuleDocGenerator \ValueObject \RuleDefinition ;
@@ -62,7 +63,12 @@ public function refactor(Node $node): ?Node
6263 return null ;
6364 }
6465
65- $ type = TypeCombinator::removeNull ($ this ->getType ($ node ->var ));
66+ $ scope = ScopeFetcher::fetch ($ node );
67+ $ type = TypeCombinator::removeNull (
68+ // This HAS to use the $scope->getType() as opposed to $this->getType()
69+ // because it's not getting the proper type from the Larastan extensions
70+ $ scope ->getType ($ node ->var )
71+ );
6672 $ valueType = $ type ->getTemplateType ('Illuminate\Support\Enumerable ' , 'TValue ' );
6773
6874 if (! (new ObjectType ('Illuminate\Contracts\Support\Arrayable ' ))->isSuperTypeOf ($ valueType )->no ()) {
You can’t perform that action at this time.
0 commit comments