for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace PhpUnitGen\Parser\NodeParser;
use PhpParser\Node;
use PhpUnitGen\Model\FunctionModel;
use PhpUnitGen\Model\ModelInterface\PhpFileModelInterface;
/**
* Class FunctionNodeParser.
*
* @author Paul Thébaud <[email protected]>.
* @copyright 2017-2018 Paul Thébaud <[email protected]>.
* @license https://opensource.org/licenses/MIT The MIT license.
* @link https://github.com/paul-thebaud/phpunit-generator
* @since Class available since Release 2.0.0.
*/
class FunctionNodeParser extends AbstractFunctionNodeParser
{
* Parse a node to update the parent node model.
* @param Node\Stmt\Function_ $node The node to parse.
* @param PhpFileModelInterface $parent The parent node.
* @return PhpFileModelInterface The updated parent.
public function invoke(Node\Stmt\Function_ $node, PhpFileModelInterface $parent): PhpFileModelInterface
$function = new FunctionModel();
$function->setParentNode($parent);
$function->setName($node->name);
$function = $this->parseFunction($node, $function);
$parent->addFunction($function);
return $parent;
}