public function setBodyFromString($newBody) { if (!is_string($newBody)) { throw new \InvalidArgumentException('Body parameter must be a string'); } $this->node->stmts = (new ParserFactory())->create(ParserFactory::PREFER_PHP7)->parse('<?php ' . $newBody); }