Skip to content
Discussion options

You must be logged in to vote

Yes it is, you need to write a dynamic return type extension for executeStep method (https://phpstan.org/developing-extensions/dynamic-return-type-extensions).

Inside the extension you'll have to parse the file contents and invoke NodeScopeResolver by yourself to get the returned ClosureType.

Here's a pseudocode that would do that for you:

		$nodes = $this->parser->parseFile($fileName);
		$fileScope = $this->scopeFactory->create(ScopeContext::create($fileName));

		$returnType = null;

		$nodeScopeResolver->processNodes($nodes, $fileScope, static function (Node $node, Scope $scope) use (&returnType): void {
			if ($scope->getFunction() !== null) {
				return;
			}
			if (!$node instanceof

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by ThomasNunninger
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Support
Labels
None yet
2 participants