Skip to content

Commit

Permalink
Using the reflected class resolver
Browse files Browse the repository at this point in the history
  • Loading branch information
mamazu committed Mar 23, 2024
1 parent 4889c1c commit 836d962
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Microsoft\PhpParser\Node;
use Microsoft\PhpParser\Node\Expression\ObjectCreationExpression;
use Microsoft\PhpParser\Token;
use Phpactor\WorseReflection\Core\Exception\NotFound;
use Phpactor\WorseReflection\Core\Inference\Frame;
use Phpactor\WorseReflection\Core\Inference\FunctionArguments;
Expand All @@ -30,7 +31,7 @@ public function resolve(NodeContextResolver $resolver, Frame $frame, Node $node)
assert($node instanceof ObjectCreationExpression);

$className = $node->classTypeDesignator;
if (false === $className instanceof Node) {
if ($className instanceof Token) {
return $this->resolveAnonymousClass($resolver, $node);
}

Expand Down Expand Up @@ -85,10 +86,7 @@ private function resolveAnonymousClass(NodeContextResolver $resolver, Node $node
$node->getEndPosition(),
[
'symbol_type' => Symbol::CLASS_,
'type' => TypeFactory::fromStringWithReflector(
'class@anonymous:'.$node->getStartPosition(),
$resolver->reflector(),
)
'type' => TypeFactory::reflectedClass($resolver->reflector(), 'class@anonymous:'.$node->getStartPosition())
]
);
}
Expand Down

0 comments on commit 836d962

Please sign in to comment.