public function testGetReturnStatementAstDoesNotGiveInnerScopeReturnStatements()
{
$php = <<<'PHP'
<?php
function foo($a) {
$x = new class {
public function __invoke() {
return 5;
}
};
return function () use ($x) {
return $x();
};
}
PHP;
$reflector = new FunctionReflector(new StringSourceLocator($php));
$function = $reflector->reflect('foo');
$nodes = $function->getReturnStatementsAst();
$this->assertCount(1, $nodes);
$this->assertContainsOnlyInstancesOf(Return_::class, $nodes);
reset($nodes);
/** @var Return_ $first */
$first = current($nodes);
$this->assertInstanceOf(Closure::class, $first->expr);
$this->assertSame(8, $first->getAttribute('startLine'));
$this->assertSame(10, $first->getAttribute('endLine'));
}