src/Reflection/ReflectionFunctionAbstract.php
public function setBodyFromAst(array $nodes) : void
    {
        // This slightly confusing code simply type-checks the $sourceLocators
        // array by unpacking them and splatting them in the closure.
        $validator         = static function (Node ...$node) : array {
            return $node;
        };
        $this->node->stmts = $validator(...$nodes);
    }
public function setBodyFromAst(array $nodes) : void
    {
        // This slightly confusing code simply type-checks the $sourceLocators
        // array by unpacking them and splatting them in the closure.
        $validator         = static function (Node ...$node) : array {
            return $node;
        };
        $this->node->stmts = $validator(...$nodes);
    }
Override the method or function's body of statements with an entirely new
body of statements within the reflection.

@param Node[] $nodes

@example
// $ast should be an array of Nodes
$reflectionFunction->setBodyFromAst($ast);