Skip to content

Commit

Permalink
fix scope issue
Browse files Browse the repository at this point in the history
  • Loading branch information
romalytvynenko committed Jun 28, 2024
1 parent d8a88bc commit 28550ea
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/Infer/Definition/ClassDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function getMethodDefinition(string $name, Scope $scope = new GlobalScope
);

(new ReferenceTypeResolver($scope->index))
->resolveFunctionReturnReferences($scope, $this->methods[$name]->type);
->resolveFunctionReturnReferences($methodScope, $this->methods[$name]->type);

foreach ($this->methods[$name]->type->exceptions as $i => $exceptionType) {
if (ReferenceTypeResolver::hasResolvableReferences($exceptionType)) {
Expand Down
6 changes: 3 additions & 3 deletions src/Infer/Services/ReferenceTypeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ public function resolveFunctionReturnReferences(Scope $scope, FunctionType $func
}

if ($annotatedReturnType = $functionType->getAttribute('returnTypeAnnotation')) {
// $functionType->setReturnType(
// $this->addAnnotatedReturnType($functionType->getReturnType(), $annotatedReturnType)
// );
$functionType->setReturnType(
$this->addAnnotatedReturnType($functionType->getReturnType(), $annotatedReturnType)
);
}
}

Expand Down
13 changes: 0 additions & 13 deletions src/Support/RouteInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,19 +212,6 @@ public function getCodeReturnType()
->getMethodReturnType($this->methodName());
}

private function inferredTypesContainMoreConcreteAnnotatedType(array $inferredTypes, Type $annotationType): bool
{
return (bool) collect($inferredTypes)
->filter()
->first(function ($t) use ($annotationType) {
if ($t instanceof ObjectType && $annotationType instanceof ObjectType) {
return is_a($t->name, $annotationType->name, true);
}

return is_a($t::class, $annotationType::class, true);
});
}

/**
* @todo Maybe better name is needed as this method performs method analysis, indexes building, etc.
*/
Expand Down

0 comments on commit 28550ea

Please sign in to comment.