for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php declare(strict_types=1);
namespace Stratadox\PhpGenerics\Generator\Visitor;
use PhpParser\Node;
use PhpParser\Node\Expr\StaticCall;
use PhpParser\Node\Name;
use PhpParser\NodeVisitorAbstract;
use ReflectionClass;
final class ParentBypass extends NodeVisitorAbstract
{
/** @var ReflectionClass|null */
private $parent;
public function __construct(ReflectionClass $genericBase) {
$parent = $genericBase->getParentClass();
if ($parent) {
$this->parent = $parent;
}
public function enterNode(Node $node)
if (null === $this->parent) {
return;
if (!$node instanceof StaticCall) {
if ((string) $node->class !== 'parent') {
$node->class = new Name($this->parent->getShortName());