public function setBodyFromClosure(\Closure $newBody) { $closureData = (new AstAnalyzer())->analyze($newBody); if (!isset($closureData['ast']) || !$closureData['ast'] instanceof ClosureNode) { throw new Exception\ClosureAstExtractionFailure('Failed to extract AST from closure - AST data not returned by AstAnalyzer'); } $this->node->stmts = $closureData['ast']->stmts; }