diff --git a/app/assets/css/app.css b/app/assets/css/app.css index bd6213e..2716238 100644 --- a/app/assets/css/app.css +++ b/app/assets/css/app.css @@ -1,3 +1,11 @@ @tailwind base; @tailwind components; -@tailwind utilities; \ No newline at end of file +@tailwind utilities; + +#clickable-nodes-code a.active-node { + color: forestgreen; +} + +pre code.hljs { + border-radius: .6em; +} \ No newline at end of file diff --git a/app/assets/js/app/editor.js b/app/assets/js/app/editor.js index 2d54192..a6877a3 100644 --- a/app/assets/js/app/editor.js +++ b/app/assets/js/app/editor.js @@ -233,17 +233,10 @@ export function initAstEditor() { : [ 'render('ast/create.html.twig', [ 'form' => $form->createView(), - 'example' => $createAstRunRequest, + 'astRun' => $createAstRunRequest, ]); } #[Route('/ast/{astRunIdHash}/{activeNodeId}', name: 'app_ast_display', defaults: ['activeNodeId' => null], methods: ['GET'])] - public function displayExample(EntityManagerInterface $em, string $astRunIdHash, int|null $activeNodeId = null): Response + public function displayExample(EntityManagerInterface $em, string $astRunIdHash, ?int $activeNodeId = null): Response { /** @var AstRun|null $astRun */ $astRun = $em->find(AstRun::class, $this->hashids->decode($astRunIdHash)[0]); @@ -161,6 +152,7 @@ public function displayExample(EntityManagerInterface $em, string $astRunIdHash, 'astRun' => $createAstRequest, 'clickableNodesDump' => $this->makeNodeClickable($nodes, $astRunIdHash, $activeNodeId), 'simpleNodeDump' => $simpleNodeDump, + 'targetNodeClass' => $targetNodeClass, ]); } @@ -177,13 +169,18 @@ private function makeNodeClickable(array $nodes, string $uuid, ?int $activeNodeI private function resolveTargetNodeClass(Node $node): string { if ($node instanceof UseUse || $node instanceof AttributeGroup) { + /** @var Node $parentNode */ $parentNode = $node->getAttribute('parent'); + return $parentNode::class; } if ($node instanceof Attribute) { + /** @var Node $attributeGroup */ $attributeGroup = $node->getAttribute('parent'); + /** @var Node $stmt */ $stmt = $attributeGroup->getAttribute('parent'); + return $stmt::class; } @@ -202,7 +199,9 @@ private function resolveTargetNodeClass(Node $node): string // target one level up if ($node instanceof Identifier || $node instanceof Name || $node instanceof Variable) { + /** @var Node $parentNode */ $parentNode = $node->getAttribute('parent'); + return $this->resolveTargetNodeClass($parentNode); } diff --git a/app/src/Entity/AstRun.php b/app/src/Entity/AstRun.php index d88eec3..0ad312d 100644 --- a/app/src/Entity/AstRun.php +++ b/app/src/Entity/AstRun.php @@ -91,4 +91,19 @@ public static function hashInput(string $code): string { return md5($code); } + + public function getCreatedAt(): DateTimeImmutable + { + return $this->createdAt; + } + + public function getIdHash(): ?string + { + return $this->idHash; + } + + public function getInputHash(): string + { + return $this->inputHash; + } } diff --git a/app/src/PhpParser/AttributeKey.php b/app/src/PhpParser/AttributeKey.php index b126513..7210d94 100644 --- a/app/src/PhpParser/AttributeKey.php +++ b/app/src/PhpParser/AttributeKey.php @@ -1,4 +1,59 @@ getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pParam($param) ); } @@ -175,11 +232,12 @@ protected function pParam(Param $param): string protected function pArg(Arg $arg): string { $nodeId = $arg->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pArg($arg) ); } @@ -187,11 +245,12 @@ protected function pArg(Arg $arg): string protected function pVariadicPlaceholder(VariadicPlaceholder $variadicPlaceholder): string { $nodeId = $variadicPlaceholder->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pVariadicPlaceholder($variadicPlaceholder) ); } @@ -199,11 +258,12 @@ protected function pVariadicPlaceholder(VariadicPlaceholder $variadicPlaceholder protected function pConst(Const_ $const): string { $nodeId = $const->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pConst($const) ); } @@ -211,11 +271,12 @@ protected function pConst(Const_ $const): string protected function pNullableType(NullableType $nullableType): string { $nodeId = $nullableType->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pNullableType($nullableType) ); } @@ -223,11 +284,12 @@ protected function pNullableType(NullableType $nullableType): string protected function pUnionType(UnionType $unionType): string { $nodeId = $unionType->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pUnionType($unionType) ); } @@ -235,11 +297,12 @@ protected function pUnionType(UnionType $unionType): string protected function pIntersectionType(IntersectionType $intersectionType): string { $nodeId = $intersectionType->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pIntersectionType($intersectionType) ); } @@ -247,11 +310,12 @@ protected function pIntersectionType(IntersectionType $intersectionType): string protected function pIdentifier(Identifier $identifier): string { $nodeId = $identifier->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pIdentifier($identifier) ); } @@ -259,11 +323,12 @@ protected function pIdentifier(Identifier $identifier): string protected function pVarLikeIdentifier(VarLikeIdentifier $varLikeIdentifier): string { $nodeId = $varLikeIdentifier->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pVarLikeIdentifier($varLikeIdentifier) ); } @@ -271,11 +336,12 @@ protected function pVarLikeIdentifier(VarLikeIdentifier $varLikeIdentifier): str protected function pAttribute(Attribute $attribute): string { $nodeId = $attribute->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pAttribute($attribute) ); } @@ -283,11 +349,12 @@ protected function pAttribute(Attribute $attribute): string protected function pAttributeGroup(AttributeGroup $attributeGroup): string { $nodeId = $attributeGroup->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pAttributeGroup($attributeGroup) ); } @@ -295,11 +362,12 @@ protected function pAttributeGroup(AttributeGroup $attributeGroup): string protected function pName(Name $name): string { $nodeId = $name->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pName($name) ); } @@ -307,11 +375,12 @@ protected function pName(Name $name): string protected function pName_FullyQualified(FullyQualified $fullyQualified): string { $nodeId = $fullyQualified->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pName_FullyQualified($fullyQualified) ); } @@ -319,11 +388,12 @@ protected function pName_FullyQualified(FullyQualified $fullyQualified): string protected function pName_Relative(Relative $relative): string { $nodeId = $relative->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pName_Relative($relative) ); } @@ -331,11 +401,12 @@ protected function pName_Relative(Relative $relative): string protected function pScalar_MagicConst_Class(Class_ $class): string { $nodeId = $class->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pScalar_MagicConst_Class($class) ); } @@ -343,11 +414,12 @@ protected function pScalar_MagicConst_Class(Class_ $class): string protected function pScalar_MagicConst_Dir(Dir $dir): string { $nodeId = $dir->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pScalar_MagicConst_Dir($dir) ); } @@ -355,11 +427,12 @@ protected function pScalar_MagicConst_Dir(Dir $dir): string protected function pScalar_MagicConst_File(File $file): string { $nodeId = $file->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pScalar_MagicConst_File($file) ); } @@ -367,11 +440,12 @@ protected function pScalar_MagicConst_File(File $file): string protected function pScalar_MagicConst_Function(Function_ $function): string { $nodeId = $function->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pScalar_MagicConst_Function($function) ); } @@ -379,11 +453,12 @@ protected function pScalar_MagicConst_Function(Function_ $function): string protected function pScalar_MagicConst_Line(Line $line): string { $nodeId = $line->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pScalar_MagicConst_Line($line) ); } @@ -391,11 +466,12 @@ protected function pScalar_MagicConst_Line(Line $line): string protected function pScalar_MagicConst_Method(Method $method): string { $nodeId = $method->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pScalar_MagicConst_Method($method) ); } @@ -403,11 +479,12 @@ protected function pScalar_MagicConst_Method(Method $method): string protected function pScalar_MagicConst_Namespace(Namespace_ $namespace): string { $nodeId = $namespace->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pScalar_MagicConst_Namespace($namespace) ); } @@ -415,11 +492,12 @@ protected function pScalar_MagicConst_Namespace(Namespace_ $namespace): string protected function pScalar_MagicConst_Trait(Trait_ $trait): string { $nodeId = $trait->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pScalar_MagicConst_Trait($trait) ); } @@ -427,11 +505,12 @@ protected function pScalar_MagicConst_Trait(Trait_ $trait): string protected function pScalar_String(String_ $string): string { $nodeId = $string->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pScalar_String($string) ); } @@ -439,11 +518,12 @@ protected function pScalar_String(String_ $string): string protected function pScalar_Encapsed(Encapsed $encapsed): string { $nodeId = $encapsed->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pScalar_Encapsed($encapsed) ); } @@ -451,11 +531,12 @@ protected function pScalar_Encapsed(Encapsed $encapsed): string protected function pScalar_LNumber(LNumber $lNumber): string { $nodeId = $lNumber->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pScalar_LNumber($lNumber) ); } @@ -463,11 +544,12 @@ protected function pScalar_LNumber(LNumber $lNumber): string protected function pScalar_DNumber(DNumber $dNumber): string { $nodeId = $dNumber->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pScalar_DNumber($dNumber) ); } @@ -475,11 +557,12 @@ protected function pScalar_DNumber(DNumber $dNumber): string protected function pScalar_EncapsedStringPart(EncapsedStringPart $encapsedStringPart): string { $nodeId = $encapsedStringPart->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pScalar_EncapsedStringPart($encapsedStringPart) ); } @@ -495,11 +578,12 @@ protected function pExpr_Assign(Assign $assign): string protected function pExpr_AssignRef(AssignRef $assignRef): string { $nodeId = $assignRef->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_AssignRef($assignRef) ); } @@ -507,11 +591,12 @@ protected function pExpr_AssignRef(AssignRef $assignRef): string protected function pExpr_AssignOp_Plus(Plus $plus): string { $nodeId = $plus->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_AssignOp_Plus($plus) ); } @@ -519,11 +604,12 @@ protected function pExpr_AssignOp_Plus(Plus $plus): string protected function pExpr_AssignOp_Minus(Minus $minus): string { $nodeId = $minus->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_AssignOp_Minus($minus) ); } @@ -531,11 +617,12 @@ protected function pExpr_AssignOp_Minus(Minus $minus): string protected function pExpr_AssignOp_Mul(Mul $mul): string { $nodeId = $mul->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_AssignOp_Mul($mul) ); } @@ -543,11 +630,12 @@ protected function pExpr_AssignOp_Mul(Mul $mul): string protected function pExpr_AssignOp_Div(Div $div): string { $nodeId = $div->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_AssignOp_Div($div) ); } @@ -555,11 +643,12 @@ protected function pExpr_AssignOp_Div(Div $div): string protected function pExpr_AssignOp_Concat(Concat $concat): string { $nodeId = $concat->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_AssignOp_Concat($concat) ); } @@ -567,11 +656,12 @@ protected function pExpr_AssignOp_Concat(Concat $concat): string protected function pExpr_AssignOp_Mod(Mod $mod): string { $nodeId = $mod->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_AssignOp_Mod($mod) ); } @@ -579,11 +669,12 @@ protected function pExpr_AssignOp_Mod(Mod $mod): string protected function pExpr_AssignOp_BitwiseAnd(BitwiseAnd $bitwiseAnd): string { $nodeId = $bitwiseAnd->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_AssignOp_BitwiseAnd($bitwiseAnd) ); } @@ -591,11 +682,12 @@ protected function pExpr_AssignOp_BitwiseAnd(BitwiseAnd $bitwiseAnd): string protected function pExpr_AssignOp_BitwiseOr(BitwiseOr $bitwiseOr): string { $nodeId = $bitwiseOr->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_AssignOp_BitwiseOr($bitwiseOr) ); } @@ -603,11 +695,12 @@ protected function pExpr_AssignOp_BitwiseOr(BitwiseOr $bitwiseOr): string protected function pExpr_AssignOp_BitwiseXor(BitwiseXor $bitwiseXor): string { $nodeId = $bitwiseXor->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_AssignOp_BitwiseXor($bitwiseXor) ); } @@ -615,11 +708,12 @@ protected function pExpr_AssignOp_BitwiseXor(BitwiseXor $bitwiseXor): string protected function pExpr_AssignOp_ShiftLeft(ShiftLeft $shiftLeft): string { $nodeId = $shiftLeft->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_AssignOp_ShiftLeft($shiftLeft) ); } @@ -627,11 +721,12 @@ protected function pExpr_AssignOp_ShiftLeft(ShiftLeft $shiftLeft): string protected function pExpr_AssignOp_ShiftRight(ShiftRight $shiftRight): string { $nodeId = $shiftRight->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_AssignOp_ShiftRight($shiftRight) ); } @@ -639,11 +734,12 @@ protected function pExpr_AssignOp_ShiftRight(ShiftRight $shiftRight): string protected function pExpr_AssignOp_Pow(Pow $pow): string { $nodeId = $pow->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_AssignOp_Pow($pow) ); } @@ -651,83 +747,90 @@ protected function pExpr_AssignOp_Pow(Pow $pow): string protected function pExpr_AssignOp_Coalesce(Coalesce $coalesce): string { $nodeId = $coalesce->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_AssignOp_Coalesce($coalesce) ); } - protected function pExpr_BinaryOp_Plus(\PhpParser\Node\Expr\BinaryOp\Plus $plus): string + protected function pExpr_BinaryOp_Plus(Node\Expr\BinaryOp\Plus $plus): string { $nodeId = $plus->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_BinaryOp_Plus($plus) ); } - protected function pExpr_BinaryOp_Minus(\PhpParser\Node\Expr\BinaryOp\Minus $minus): string + protected function pExpr_BinaryOp_Minus(Node\Expr\BinaryOp\Minus $minus): string { $nodeId = $minus->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_BinaryOp_Minus($minus) ); } - protected function pExpr_BinaryOp_Mul(\PhpParser\Node\Expr\BinaryOp\Mul $mul): string + protected function pExpr_BinaryOp_Mul(Node\Expr\BinaryOp\Mul $mul): string { $nodeId = $mul->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_BinaryOp_Mul($mul) ); } - protected function pExpr_BinaryOp_Div(\PhpParser\Node\Expr\BinaryOp\Div $div): string + protected function pExpr_BinaryOp_Div(Node\Expr\BinaryOp\Div $div): string { $nodeId = $div->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_BinaryOp_Div($div) ); } - protected function pExpr_BinaryOp_Concat(\PhpParser\Node\Expr\BinaryOp\Concat $concat): string + protected function pExpr_BinaryOp_Concat(Node\Expr\BinaryOp\Concat $concat): string { $nodeId = $concat->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_BinaryOp_Concat($concat) ); } - protected function pExpr_BinaryOp_Mod(\PhpParser\Node\Expr\BinaryOp\Mod $mod): string + protected function pExpr_BinaryOp_Mod(Node\Expr\BinaryOp\Mod $mod): string { $nodeId = $mod->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_BinaryOp_Mod($mod) ); } @@ -735,11 +838,12 @@ protected function pExpr_BinaryOp_Mod(\PhpParser\Node\Expr\BinaryOp\Mod $mod): s protected function pExpr_BinaryOp_BooleanAnd(BooleanAnd $booleanAnd): string { $nodeId = $booleanAnd->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_BinaryOp_BooleanAnd($booleanAnd) ); } @@ -747,83 +851,90 @@ protected function pExpr_BinaryOp_BooleanAnd(BooleanAnd $booleanAnd): string protected function pExpr_BinaryOp_BooleanOr(BooleanOr $booleanOr): string { $nodeId = $booleanOr->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_BinaryOp_BooleanOr($booleanOr) ); } - protected function pExpr_BinaryOp_BitwiseAnd(\PhpParser\Node\Expr\BinaryOp\BitwiseAnd $bitwiseAnd): string + protected function pExpr_BinaryOp_BitwiseAnd(Node\Expr\BinaryOp\BitwiseAnd $bitwiseAnd): string { $nodeId = $bitwiseAnd->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_BinaryOp_BitwiseAnd($bitwiseAnd) ); } - protected function pExpr_BinaryOp_BitwiseOr(\PhpParser\Node\Expr\BinaryOp\BitwiseOr $bitwiseOr): string + protected function pExpr_BinaryOp_BitwiseOr(Node\Expr\BinaryOp\BitwiseOr $bitwiseOr): string { $nodeId = $bitwiseOr->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_BinaryOp_BitwiseOr($bitwiseOr) ); } - protected function pExpr_BinaryOp_BitwiseXor(\PhpParser\Node\Expr\BinaryOp\BitwiseXor $bitwiseXor): string + protected function pExpr_BinaryOp_BitwiseXor(Node\Expr\BinaryOp\BitwiseXor $bitwiseXor): string { $nodeId = $bitwiseXor->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_BinaryOp_BitwiseXor($bitwiseXor) ); } - protected function pExpr_BinaryOp_ShiftLeft(\PhpParser\Node\Expr\BinaryOp\ShiftLeft $shiftLeft): string + protected function pExpr_BinaryOp_ShiftLeft(Node\Expr\BinaryOp\ShiftLeft $shiftLeft): string { $nodeId = $shiftLeft->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_BinaryOp_ShiftLeft($shiftLeft) ); } - protected function pExpr_BinaryOp_ShiftRight(\PhpParser\Node\Expr\BinaryOp\ShiftRight $shiftRight): string + protected function pExpr_BinaryOp_ShiftRight(Node\Expr\BinaryOp\ShiftRight $shiftRight): string { $nodeId = $shiftRight->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_BinaryOp_ShiftRight($shiftRight) ); } - protected function pExpr_BinaryOp_Pow(\PhpParser\Node\Expr\BinaryOp\Pow $pow): string + protected function pExpr_BinaryOp_Pow(Node\Expr\BinaryOp\Pow $pow): string { $nodeId = $pow->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_BinaryOp_Pow($pow) ); } @@ -831,11 +942,12 @@ protected function pExpr_BinaryOp_Pow(\PhpParser\Node\Expr\BinaryOp\Pow $pow): s protected function pExpr_BinaryOp_LogicalAnd(LogicalAnd $logicalAnd): string { $nodeId = $logicalAnd->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_BinaryOp_LogicalAnd($logicalAnd) ); } @@ -843,11 +955,12 @@ protected function pExpr_BinaryOp_LogicalAnd(LogicalAnd $logicalAnd): string protected function pExpr_BinaryOp_LogicalOr(LogicalOr $logicalOr): string { $nodeId = $logicalOr->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_BinaryOp_LogicalOr($logicalOr) ); } @@ -995,7 +1108,7 @@ protected function pExpr_BinaryOp_SmallerOrEqual(SmallerOrEqual $smallerOrEqual) return $this->pInfixOp(SmallerOrEqual::class, $smallerOrEqual->left, $link, $smallerOrEqual->right); } - protected function pExpr_BinaryOp_Coalesce(\PhpParser\Node\Expr\BinaryOp\Coalesce $coalesce): string + protected function pExpr_BinaryOp_Coalesce(Node\Expr\BinaryOp\Coalesce $coalesce): string { $nodeId = $coalesce->getAttribute(AttributeKey::NODE_ID); @@ -1006,17 +1119,18 @@ protected function pExpr_BinaryOp_Coalesce(\PhpParser\Node\Expr\BinaryOp\Coalesc $this->activeNodeId ); - return $this->pInfixOp(\PhpParser\Node\Expr\BinaryOp\Coalesce::class, $coalesce->left, $link, $coalesce->right); + return $this->pInfixOp(Node\Expr\BinaryOp\Coalesce::class, $coalesce->left, $link, $coalesce->right); } protected function pExpr_Instanceof(Instanceof_ $instanceof): string { $nodeId = $instanceof->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_Instanceof($instanceof) ); } @@ -1024,11 +1138,12 @@ protected function pExpr_Instanceof(Instanceof_ $instanceof): string protected function pExpr_BooleanNot(BooleanNot $booleanNot): string { $nodeId = $booleanNot->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_BooleanNot($booleanNot) ); } @@ -1036,11 +1151,12 @@ protected function pExpr_BooleanNot(BooleanNot $booleanNot): string protected function pExpr_BitwiseNot(BitwiseNot $bitwiseNot): string { $nodeId = $bitwiseNot->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_BitwiseNot($bitwiseNot) ); } @@ -1048,11 +1164,12 @@ protected function pExpr_BitwiseNot(BitwiseNot $bitwiseNot): string protected function pExpr_UnaryMinus(UnaryMinus $unaryMinus): string { $nodeId = $unaryMinus->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_UnaryMinus($unaryMinus) ); } @@ -1060,11 +1177,12 @@ protected function pExpr_UnaryMinus(UnaryMinus $unaryMinus): string protected function pExpr_UnaryPlus(UnaryPlus $unaryPlus): string { $nodeId = $unaryPlus->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_UnaryPlus($unaryPlus) ); } @@ -1072,11 +1190,12 @@ protected function pExpr_UnaryPlus(UnaryPlus $unaryPlus): string protected function pExpr_PreInc(PreInc $preInc): string { $nodeId = $preInc->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_PreInc($preInc) ); } @@ -1084,11 +1203,12 @@ protected function pExpr_PreInc(PreInc $preInc): string protected function pExpr_PreDec(PreDec $preDec): string { $nodeId = $preDec->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_PreDec($preDec) ); } @@ -1096,11 +1216,12 @@ protected function pExpr_PreDec(PreDec $preDec): string protected function pExpr_PostInc(PostInc $postInc): string { $nodeId = $postInc->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_PostInc($postInc) ); } @@ -1108,11 +1229,12 @@ protected function pExpr_PostInc(PostInc $postInc): string protected function pExpr_PostDec(PostDec $postDec): string { $nodeId = $postDec->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_PostDec($postDec) ); } @@ -1120,11 +1242,12 @@ protected function pExpr_PostDec(PostDec $postDec): string protected function pExpr_ErrorSuppress(ErrorSuppress $errorSuppress): string { $nodeId = $errorSuppress->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_ErrorSuppress($errorSuppress) ); } @@ -1132,11 +1255,12 @@ protected function pExpr_ErrorSuppress(ErrorSuppress $errorSuppress): string protected function pExpr_YieldFrom(YieldFrom $yieldFrom): string { $nodeId = $yieldFrom->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_YieldFrom($yieldFrom) ); } @@ -1144,11 +1268,12 @@ protected function pExpr_YieldFrom(YieldFrom $yieldFrom): string protected function pExpr_Print(Print_ $print): string { $nodeId = $print->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_Print($print) ); } @@ -1156,11 +1281,12 @@ protected function pExpr_Print(Print_ $print): string protected function pExpr_Cast_Int(Int_ $int): string { $nodeId = $int->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_Cast_Int($int) ); } @@ -1168,23 +1294,25 @@ protected function pExpr_Cast_Int(Int_ $int): string protected function pExpr_Cast_Double(Double $double): string { $nodeId = $double->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_Cast_Double($double) ); } - protected function pExpr_Cast_String(\PhpParser\Node\Expr\Cast\String_ $string): string + protected function pExpr_Cast_String(Node\Expr\Cast\String_ $string): string { $nodeId = $string->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_Cast_String($string) ); } @@ -1192,11 +1320,12 @@ protected function pExpr_Cast_String(\PhpParser\Node\Expr\Cast\String_ $string): protected function pExpr_Cast_Array(Array_ $array): string { $nodeId = $array->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_Cast_Array($array) ); } @@ -1204,11 +1333,12 @@ protected function pExpr_Cast_Array(Array_ $array): string protected function pExpr_Cast_Object(Object_ $object): string { $nodeId = $object->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_Cast_Object($object) ); } @@ -1216,11 +1346,12 @@ protected function pExpr_Cast_Object(Object_ $object): string protected function pExpr_Cast_Bool(Bool_ $bool): string { $nodeId = $bool->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_Cast_Bool($bool) ); } @@ -1228,11 +1359,12 @@ protected function pExpr_Cast_Bool(Bool_ $bool): string protected function pExpr_Cast_Unset(Unset_ $unset): string { $nodeId = $unset->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_Cast_Unset($unset) ); } @@ -1240,11 +1372,12 @@ protected function pExpr_Cast_Unset(Unset_ $unset): string protected function pExpr_FuncCall(FuncCall $funcCall): string { $nodeId = $funcCall->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_FuncCall($funcCall) ); } @@ -1260,7 +1393,7 @@ protected function pExpr_MethodCall(MethodCall $methodCall): string '->', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', ); return $this->pDereferenceLhs($methodCall->var) . $link . $this->pObjectProperty($methodCall->name) @@ -1270,11 +1403,12 @@ protected function pExpr_MethodCall(MethodCall $methodCall): string protected function pExpr_NullsafeMethodCall(NullsafeMethodCall $nullsafeMethodCall): string { $nodeId = $nullsafeMethodCall->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_NullsafeMethodCall($nullsafeMethodCall) ); } @@ -1282,11 +1416,12 @@ protected function pExpr_NullsafeMethodCall(NullsafeMethodCall $nullsafeMethodCa protected function pExpr_StaticCall(StaticCall $staticCall): string { $nodeId = $staticCall->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_StaticCall($staticCall) ); } @@ -1294,11 +1429,12 @@ protected function pExpr_StaticCall(StaticCall $staticCall): string protected function pExpr_Empty(Empty_ $empty): string { $nodeId = $empty->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_Empty($empty) ); } @@ -1306,11 +1442,12 @@ protected function pExpr_Empty(Empty_ $empty): string protected function pExpr_Isset(Isset_ $isset): string { $nodeId = $isset->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_Isset($isset) ); } @@ -1318,11 +1455,12 @@ protected function pExpr_Isset(Isset_ $isset): string protected function pExpr_Eval(Eval_ $eval): string { $nodeId = $eval->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_Eval($eval) ); } @@ -1330,11 +1468,12 @@ protected function pExpr_Eval(Eval_ $eval): string protected function pExpr_Include(Include_ $include): string { $nodeId = $include->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_Include($include) ); } @@ -1342,11 +1481,12 @@ protected function pExpr_Include(Include_ $include): string protected function pExpr_List(List_ $list): string { $nodeId = $list->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_List($list) ); } @@ -1354,11 +1494,12 @@ protected function pExpr_List(List_ $list): string protected function pExpr_Error(Error $error): string { $nodeId = $error->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_Error($error) ); } @@ -1366,23 +1507,25 @@ protected function pExpr_Error(Error $error): string protected function pExpr_Variable(Variable $variable): string { $nodeId = $variable->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_Variable($variable) ); } - protected function pExpr_Array(\PhpParser\Node\Expr\Array_ $array): string + protected function pExpr_Array(Node\Expr\Array_ $array): string { $nodeId = $array->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_Array($array) ); } @@ -1390,11 +1533,12 @@ protected function pExpr_Array(\PhpParser\Node\Expr\Array_ $array): string protected function pExpr_ArrayItem(ArrayItem $arrayItem): string { $nodeId = $arrayItem->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_ArrayItem($arrayItem) ); } @@ -1402,11 +1546,12 @@ protected function pExpr_ArrayItem(ArrayItem $arrayItem): string protected function pExpr_ArrayDimFetch(ArrayDimFetch $arrayDimFetch): string { $nodeId = $arrayDimFetch->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_ArrayDimFetch($arrayDimFetch) ); } @@ -1414,11 +1559,12 @@ protected function pExpr_ArrayDimFetch(ArrayDimFetch $arrayDimFetch): string protected function pExpr_ConstFetch(ConstFetch $constFetch): string { $nodeId = $constFetch->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_ConstFetch($constFetch) ); } @@ -1431,7 +1577,7 @@ protected function pExpr_ClassConstFetch(ClassConstFetch $classConstFetch): stri '::', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', ); return $this->pStaticDereferenceLhs($classConstFetch->class) . $link . $this->pObjectProperty( @@ -1450,11 +1596,12 @@ protected function pExpr_PropertyFetch(PropertyFetch $propertyFetch): string protected function pExpr_NullsafePropertyFetch(NullsafePropertyFetch $nullsafePropertyFetch): string { $nodeId = $nullsafePropertyFetch->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_NullsafePropertyFetch($nullsafePropertyFetch) ); } @@ -1462,11 +1609,12 @@ protected function pExpr_NullsafePropertyFetch(NullsafePropertyFetch $nullsafePr protected function pExpr_StaticPropertyFetch(StaticPropertyFetch $staticPropertyFetch): string { $nodeId = $staticPropertyFetch->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_StaticPropertyFetch($staticPropertyFetch) ); } @@ -1474,11 +1622,12 @@ protected function pExpr_StaticPropertyFetch(StaticPropertyFetch $staticProperty protected function pExpr_ShellExec(ShellExec $shellExec): string { $nodeId = $shellExec->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_ShellExec($shellExec) ); } @@ -1486,11 +1635,12 @@ protected function pExpr_ShellExec(ShellExec $shellExec): string protected function pExpr_Closure(Closure $node): string { $nodeId = $node->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_Closure($node) ); } @@ -1498,11 +1648,12 @@ protected function pExpr_Closure(Closure $node): string protected function pExpr_Match(Match_ $match): string { $nodeId = $match->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_Match($match) ); } @@ -1510,11 +1661,12 @@ protected function pExpr_Match(Match_ $match): string protected function pMatchArm(MatchArm $matchArm): string { $nodeId = $matchArm->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pMatchArm($matchArm) ); } @@ -1522,11 +1674,12 @@ protected function pMatchArm(MatchArm $matchArm): string protected function pExpr_ArrowFunction(ArrowFunction $arrowFunction): string { $nodeId = $arrowFunction->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_ArrowFunction($arrowFunction) ); } @@ -1534,11 +1687,12 @@ protected function pExpr_ArrowFunction(ArrowFunction $arrowFunction): string protected function pExpr_ClosureUse(ClosureUse $node): string { $nodeId = $node->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_ClosureUse($node) ); } @@ -1546,11 +1700,12 @@ protected function pExpr_ClosureUse(ClosureUse $node): string protected function pExpr_New(New_ $new): string { $nodeId = $new->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_New($new) ); } @@ -1558,11 +1713,12 @@ protected function pExpr_New(New_ $new): string protected function pExpr_Clone(Clone_ $clone): string { $nodeId = $clone->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_Clone($clone) ); } @@ -1570,11 +1726,12 @@ protected function pExpr_Clone(Clone_ $clone): string protected function pExpr_Ternary(Ternary $ternary): string { $nodeId = $ternary->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_Ternary($ternary) ); } @@ -1582,11 +1739,12 @@ protected function pExpr_Ternary(Ternary $ternary): string protected function pExpr_Exit(Exit_ $exit): string { $nodeId = $exit->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_Exit($exit) ); } @@ -1594,11 +1752,12 @@ protected function pExpr_Exit(Exit_ $exit): string protected function pExpr_Throw(Throw_ $throw): string { $nodeId = $throw->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_Throw($throw) ); } @@ -1606,23 +1765,25 @@ protected function pExpr_Throw(Throw_ $throw): string protected function pExpr_Yield(Yield_ $yield): string { $nodeId = $yield->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pExpr_Yield($yield) ); } - protected function pStmt_Namespace(\PhpParser\Node\Stmt\Namespace_ $namespace): string + protected function pStmt_Namespace(Node\Stmt\Namespace_ $namespace): string { $nodeId = $namespace->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pStmt_Namespace($namespace) ); } @@ -1630,11 +1791,12 @@ protected function pStmt_Namespace(\PhpParser\Node\Stmt\Namespace_ $namespace): protected function pStmt_Use(Use_ $use): string { $nodeId = $use->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pStmt_Use($use) ); } @@ -1642,11 +1804,12 @@ protected function pStmt_Use(Use_ $use): string protected function pStmt_GroupUse(GroupUse $groupUse): string { $nodeId = $groupUse->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pStmt_GroupUse($groupUse) ); } @@ -1654,11 +1817,12 @@ protected function pStmt_GroupUse(GroupUse $groupUse): string protected function pStmt_UseUse(UseUse $useUse): string { $nodeId = $useUse->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pStmt_UseUse($useUse) ); } @@ -1666,11 +1830,12 @@ protected function pStmt_UseUse(UseUse $useUse): string protected function pStmt_Interface(Interface_ $interface): string { $nodeId = $interface->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pStmt_Interface($interface) ); } @@ -1678,35 +1843,38 @@ protected function pStmt_Interface(Interface_ $interface): string protected function pStmt_Enum(Enum_ $enum): string { $nodeId = $enum->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pStmt_Enum($enum) ); } - protected function pStmt_Class(\PhpParser\Node\Stmt\Class_ $class): string + protected function pStmt_Class(Node\Stmt\Class_ $class): string { $nodeId = $class->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pStmt_Class($class) ); } - protected function pStmt_Trait(\PhpParser\Node\Stmt\Trait_ $trait): string + protected function pStmt_Trait(Node\Stmt\Trait_ $trait): string { $nodeId = $trait->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pStmt_Trait($trait) ); } @@ -1714,11 +1882,12 @@ protected function pStmt_Trait(\PhpParser\Node\Stmt\Trait_ $trait): string protected function pStmt_EnumCase(EnumCase $enumCase): string { $nodeId = $enumCase->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pStmt_EnumCase($enumCase) ); } @@ -1726,11 +1895,12 @@ protected function pStmt_EnumCase(EnumCase $enumCase): string protected function pStmt_TraitUse(TraitUse $traitUse): string { $nodeId = $traitUse->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pStmt_TraitUse($traitUse) ); } @@ -1738,11 +1908,12 @@ protected function pStmt_TraitUse(TraitUse $traitUse): string protected function pStmt_TraitUseAdaptation_Precedence(Precedence $precedence): string { $nodeId = $precedence->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pStmt_TraitUseAdaptation_Precedence($precedence) ); } @@ -1750,11 +1921,12 @@ protected function pStmt_TraitUseAdaptation_Precedence(Precedence $precedence): protected function pStmt_TraitUseAdaptation_Alias(Alias $alias): string { $nodeId = $alias->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pStmt_TraitUseAdaptation_Alias($alias) ); } @@ -1762,11 +1934,12 @@ protected function pStmt_TraitUseAdaptation_Alias(Alias $alias): string protected function pStmt_Property(Property $property): string { $nodeId = $property->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pStmt_Property($property) ); } @@ -1774,11 +1947,12 @@ protected function pStmt_Property(Property $property): string protected function pStmt_PropertyProperty(PropertyProperty $propertyProperty): string { $nodeId = $propertyProperty->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pStmt_PropertyProperty($propertyProperty) ); } @@ -1786,11 +1960,12 @@ protected function pStmt_PropertyProperty(PropertyProperty $propertyProperty): s protected function pStmt_ClassMethod(ClassMethod $classMethod): string { $nodeId = $classMethod->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pStmt_ClassMethod($classMethod) ); } @@ -1798,35 +1973,38 @@ protected function pStmt_ClassMethod(ClassMethod $classMethod): string protected function pStmt_ClassConst(ClassConst $classConst): string { $nodeId = $classConst->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pStmt_ClassConst($classConst) ); } - protected function pStmt_Function(\PhpParser\Node\Stmt\Function_ $function): string + protected function pStmt_Function(Node\Stmt\Function_ $function): string { $nodeId = $function->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pStmt_Function($function) ); } - protected function pStmt_Const(\PhpParser\Node\Stmt\Const_ $const): string + protected function pStmt_Const(Node\Stmt\Const_ $const): string { $nodeId = $const->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pStmt_Const($const) ); } @@ -1834,11 +2012,12 @@ protected function pStmt_Const(\PhpParser\Node\Stmt\Const_ $const): string protected function pStmt_Declare(Declare_ $declare): string { $nodeId = $declare->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pStmt_Declare($declare) ); } @@ -1846,11 +2025,12 @@ protected function pStmt_Declare(Declare_ $declare): string protected function pStmt_DeclareDeclare(DeclareDeclare $declareDeclare): string { $nodeId = $declareDeclare->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pStmt_DeclareDeclare($declareDeclare) ); } @@ -1858,11 +2038,12 @@ protected function pStmt_DeclareDeclare(DeclareDeclare $declareDeclare): string protected function pStmt_If(If_ $if): string { $nodeId = $if->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pStmt_If($if) ); } @@ -1870,11 +2051,12 @@ protected function pStmt_If(If_ $if): string protected function pStmt_ElseIf(ElseIf_ $elseIf): string { $nodeId = $elseIf->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pStmt_ElseIf($elseIf) ); } @@ -1882,11 +2064,12 @@ protected function pStmt_ElseIf(ElseIf_ $elseIf): string protected function pStmt_Else(Else_ $else): string { $nodeId = $else->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pStmt_Else($else) ); } @@ -1894,11 +2077,12 @@ protected function pStmt_Else(Else_ $else): string protected function pStmt_For(For_ $for): string { $nodeId = $for->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pStmt_For($for) ); } @@ -1906,11 +2090,12 @@ protected function pStmt_For(For_ $for): string protected function pStmt_Foreach(Foreach_ $foreach): string { $nodeId = $foreach->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pStmt_Foreach($foreach) ); } @@ -1918,11 +2103,12 @@ protected function pStmt_Foreach(Foreach_ $foreach): string protected function pStmt_While(While_ $while): string { $nodeId = $while->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pStmt_While($while) ); } @@ -1930,11 +2116,12 @@ protected function pStmt_While(While_ $while): string protected function pStmt_Do(Do_ $do): string { $nodeId = $do->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pStmt_Do($do) ); } @@ -1942,11 +2129,12 @@ protected function pStmt_Do(Do_ $do): string protected function pStmt_Switch(Switch_ $switch): string { $nodeId = $switch->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pStmt_Switch($switch) ); } @@ -1954,11 +2142,12 @@ protected function pStmt_Switch(Switch_ $switch): string protected function pStmt_Case(Case_ $case): string { $nodeId = $case->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pStmt_Case($case) ); } @@ -1966,11 +2155,12 @@ protected function pStmt_Case(Case_ $case): string protected function pStmt_TryCatch(TryCatch $tryCatch): string { $nodeId = $tryCatch->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pStmt_TryCatch($tryCatch) ); } @@ -1978,11 +2168,12 @@ protected function pStmt_TryCatch(TryCatch $tryCatch): string protected function pStmt_Catch(Catch_ $catch): string { $nodeId = $catch->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pStmt_Catch($catch) ); } @@ -1990,11 +2181,12 @@ protected function pStmt_Catch(Catch_ $catch): string protected function pStmt_Finally(Finally_ $finally): string { $nodeId = $finally->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pStmt_Finally($finally) ); } @@ -2002,11 +2194,12 @@ protected function pStmt_Finally(Finally_ $finally): string protected function pStmt_Break(Break_ $break): string { $nodeId = $break->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pStmt_Break($break) ); } @@ -2014,11 +2207,12 @@ protected function pStmt_Break(Break_ $break): string protected function pStmt_Continue(Continue_ $continue): string { $nodeId = $continue->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pStmt_Continue($continue) ); } @@ -2026,23 +2220,25 @@ protected function pStmt_Continue(Continue_ $continue): string protected function pStmt_Return(Return_ $return): string { $nodeId = $return->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pStmt_Return($return) ); } - protected function pStmt_Throw(\PhpParser\Node\Stmt\Throw_ $throw): string + protected function pStmt_Throw(Node\Stmt\Throw_ $throw): string { $nodeId = $throw->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pStmt_Throw($throw) ); } @@ -2050,11 +2246,12 @@ protected function pStmt_Throw(\PhpParser\Node\Stmt\Throw_ $throw): string protected function pStmt_Label(Label $label): string { $nodeId = $label->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pStmt_Label($label) ); } @@ -2062,11 +2259,12 @@ protected function pStmt_Label(Label $label): string protected function pStmt_Goto(Goto_ $goto): string { $nodeId = $goto->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pStmt_Goto($goto) ); } @@ -2074,11 +2272,12 @@ protected function pStmt_Goto(Goto_ $goto): string protected function pStmt_Expression(Expression $expression): string { $nodeId = $expression->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pStmt_Expression($expression) ); } @@ -2086,11 +2285,12 @@ protected function pStmt_Expression(Expression $expression): string protected function pStmt_Echo(Echo_ $echo): string { $nodeId = $echo->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pStmt_Echo($echo) ); } @@ -2098,11 +2298,12 @@ protected function pStmt_Echo(Echo_ $echo): string protected function pStmt_Static(Static_ $static): string { $nodeId = $static->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pStmt_Static($static) ); } @@ -2110,11 +2311,12 @@ protected function pStmt_Static(Static_ $static): string protected function pStmt_Global(Global_ $global): string { $nodeId = $global->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pStmt_Global($global) ); } @@ -2122,23 +2324,25 @@ protected function pStmt_Global(Global_ $global): string protected function pStmt_StaticVar(StaticVar $staticVar): string { $nodeId = $staticVar->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pStmt_StaticVar($staticVar) ); } - protected function pStmt_Unset(\PhpParser\Node\Stmt\Unset_ $unset): string + protected function pStmt_Unset(Node\Stmt\Unset_ $unset): string { $nodeId = $unset->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pStmt_Unset($unset) ); } @@ -2146,11 +2350,12 @@ protected function pStmt_Unset(\PhpParser\Node\Stmt\Unset_ $unset): string protected function pStmt_InlineHTML(InlineHTML $inlineHTML): string { $nodeId = $inlineHTML->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pStmt_InlineHTML($inlineHTML) ); } @@ -2158,11 +2363,12 @@ protected function pStmt_InlineHTML(InlineHTML $inlineHTML): string protected function pStmt_HaltCompiler(HaltCompiler $haltCompiler): string { $nodeId = $haltCompiler->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pStmt_HaltCompiler($haltCompiler) ); } @@ -2170,11 +2376,12 @@ protected function pStmt_HaltCompiler(HaltCompiler $haltCompiler): string protected function pStmt_Nop(Nop $nop): string { $nodeId = $nop->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pStmt_Nop($nop) ); } @@ -2182,11 +2389,12 @@ protected function pStmt_Nop(Nop $nop): string protected function pObjectProperty($node): string { $nodeId = $node->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pObjectProperty($node) ); } @@ -2194,11 +2402,12 @@ protected function pObjectProperty($node): string protected function pDereferenceLhs(Node $node): string { $nodeId = $node->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pDereferenceLhs($node) ); } @@ -2206,11 +2415,12 @@ protected function pDereferenceLhs(Node $node): string protected function pCallLhs(Node $node): string { $nodeId = $node->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pCallLhs($node) ); } @@ -2218,11 +2428,12 @@ protected function pCallLhs(Node $node): string protected function pNewVariable(Node $node): string { $nodeId = $node->getAttribute(AttributeKey::NODE_ID); + return sprintf( '%s', $this->idHash, $nodeId, - $this->activeNodeId == $nodeId ? 'class="active-node"' : '', + $this->activeNodeId === $nodeId ? 'class="active-node"' : '', parent::pNewVariable($node) ); } diff --git a/app/src/PhpParser/NodeResolver/FocusedNodeResolver.php b/app/src/PhpParser/NodeResolver/FocusedNodeResolver.php index 4c2f8ad..1bdb835 100644 --- a/app/src/PhpParser/NodeResolver/FocusedNodeResolver.php +++ b/app/src/PhpParser/NodeResolver/FocusedNodeResolver.php @@ -1,4 +1,59 @@ %s', $uuid, $nodeId, - $activeNodeId == $nodeId ? 'class="active-node"' : '', + $activeNodeId === $nodeId ? 'class="active-node"' : '', $contents ); } diff --git a/app/src/PhpParser/SimpleNodeDumper.php b/app/src/PhpParser/SimpleNodeDumper.php index 25b8406..45d0675 100644 --- a/app/src/PhpParser/SimpleNodeDumper.php +++ b/app/src/PhpParser/SimpleNodeDumper.php @@ -1,9 +1,70 @@ $value) { $result .= "\n " . $key . ': '; + if ($value === null) { $result .= 'null'; - } elseif ($value === \false) { + } elseif ($value === false) { $result .= 'false'; - } elseif ($value === \true) { + } elseif ($value === true) { $result .= 'true'; - } elseif (\is_string($value)) { + } elseif (is_string($value)) { $result .= '"' . $value . '"'; - } elseif (\is_scalar($value)) { + } elseif (is_scalar($value)) { $result .= $value; } else { - $result .= \str_replace("\n", "\n ", self::dump($value, \false)); + $result .= str_replace("\n", "\n ", self::dump($value, false)); } } - if (\count($node) === 0) { + + if (count($node) === 0) { $result .= ']'; } else { $result .= "\n]"; } + return $result; } + /** * @param mixed[] $items */ - private static function isStringList(array $items) : bool + private static function isStringList(array $items): bool { foreach ($items as $item) { - if (!\is_string($item)) { - return \false; + if (!is_string($item)) { + return false; } } - return \true; + + return true; } - /** - * @param mixed $flags - */ - private static function dumpFlags($flags) : string + + private static function dumpFlags($flags): string { $strs = []; + if (($flags & Class_::MODIFIER_PUBLIC) !== 0) { $strs[] = 'MODIFIER_PUBLIC'; } + if (($flags & Class_::MODIFIER_PROTECTED) !== 0) { $strs[] = 'MODIFIER_PROTECTED'; } + if (($flags & Class_::MODIFIER_PRIVATE) !== 0) { $strs[] = 'MODIFIER_PRIVATE'; } + if (($flags & Class_::MODIFIER_ABSTRACT) !== 0) { $strs[] = 'MODIFIER_ABSTRACT'; } + if (($flags & Class_::MODIFIER_STATIC) !== 0) { $strs[] = 'MODIFIER_STATIC'; } + if (($flags & Class_::MODIFIER_FINAL) !== 0) { $strs[] = 'MODIFIER_FINAL'; } + if (($flags & Class_::MODIFIER_READONLY) !== 0) { $strs[] = 'MODIFIER_READONLY'; } + if ($strs !== []) { - return \implode(' | ', $strs) . ' (' . $flags . ')'; + return implode(' | ', $strs) . ' (' . $flags . ')'; } + return (string) $flags; } + /** * @param int|float|string $type */ - private static function dumpIncludeType($type) : string + private static function dumpIncludeType($type): string { $map = [Include_::TYPE_INCLUDE => 'TYPE_INCLUDE', Include_::TYPE_INCLUDE_ONCE => 'TYPE_INCLUDE_ONCE', Include_::TYPE_REQUIRE => 'TYPE_REQUIRE', Include_::TYPE_REQUIRE_ONCE => 'TYPE_REQUIRE_ONCE']; + if (!isset($map[$type])) { return (string) $type; } + return $map[$type] . ' (' . $type . ')'; } - /** - * @param mixed $type - */ - private static function dumpUseType($type) : string + + private static function dumpUseType($type): string { $map = [Use_::TYPE_UNKNOWN => 'TYPE_UNKNOWN', Use_::TYPE_NORMAL => 'TYPE_NORMAL', Use_::TYPE_FUNCTION => 'TYPE_FUNCTION', Use_::TYPE_CONSTANT => 'TYPE_CONSTANT']; + if (!isset($map[$type])) { return (string) $type; } + return $map[$type] . ' (' . $type . ')'; } - private static function dumpSingleNode(Node $node) : string + + private static function dumpSingleNode(Node $node): string { - $result = \get_class($node); + $result = $node::class; + // print simple nodes on same line, to make output more readable - if ($node instanceof Variable && \is_string($node->name)) { + if ($node instanceof Variable && is_string($node->name)) { $result .= '( name: "' . $node->name . '" )'; } elseif ($node instanceof Identifier) { $result .= '( name: "' . $node->name . '" )'; } elseif ($node instanceof Name) { - $result .= '( parts: ' . \json_encode($node->getParts(), 0) . ' )'; + $result .= '( parts: ' . json_encode($node->getParts(), 0) . ' )'; } elseif ($node instanceof Scalar && $node->getSubNodeNames() === ['value']) { - if (\is_string($node->value)) { + if (is_string($node->value)) { $result .= '( value: "' . $node->value . '" )'; } else { $result .= '( value: ' . $node->value . ' )'; } } else { $result .= '('; + foreach ($node->getSubNodeNames() as $key) { $result .= "\n " . $key . ': '; $value = $node->{$key}; + if ($value === null) { $result .= 'null'; - } elseif ($value === \false) { + } elseif ($value === false) { $result .= 'false'; - } elseif ($value === \true) { + } elseif ($value === true) { $result .= 'true'; - } elseif (\is_scalar($value)) { + } elseif (is_scalar($value)) { if ($key === 'flags' || $key === 'newModifier') { $result .= self::dumpFlags($value); } elseif ($key === 'type' && $node instanceof Include_) { $result .= self::dumpIncludeType($value); } elseif ($key === 'type' && ($node instanceof Use_ || $node instanceof UseUse || $node instanceof GroupUse)) { $result .= self::dumpUseType($value); - } elseif (\is_string($value)) { + } elseif (is_string($value)) { $result .= '"' . $value . '"'; } else { $result .= $value; } } else { - $result .= \str_replace("\n", "\n ", self::dump($value, \false)); + $result .= str_replace("\n", "\n ", self::dump($value, false)); } } $result .= "\n)"; } + return $result; } } diff --git a/app/src/PhpParser/SimplePhpParser.php b/app/src/PhpParser/SimplePhpParser.php index 8d3117d..6d15350 100644 --- a/app/src/PhpParser/SimplePhpParser.php +++ b/app/src/PhpParser/SimplePhpParser.php @@ -1,4 +1,59 @@ parseString($fileContent); $foundClass = $this->nodeFinder->findFirstInstanceOf($nodes, Class_::class); - if (! $foundClass instanceof Class_) { + + if (!$foundClass instanceof Class_) { throw new ShouldNotHappenException(); } @@ -69,7 +127,7 @@ public function parseString(string $fileContent): array private function ensureFileContentsHasOpeningTag(string $fileContent): string { - if (! str_starts_with(trim($fileContent), ' + {{ include('ast/_form.html.twig') }} + {% endblock %} + +{% block javascripts %} + {{ encore_entry_script_tags('ast') }} +{% endblock %} \ No newline at end of file diff --git a/app/templates/ast/index.html.twig b/app/templates/ast/index.html.twig index 3bb96c4..fd0d769 100644 --- a/app/templates/ast/index.html.twig +++ b/app/templates/ast/index.html.twig @@ -1,25 +1,61 @@ {% extends 'base.html.twig' %} -{% block title %}Hello AstController!{% endblock %} +{% block title %}AST Explorer{% endblock %} {% block body %} - Fill in the PHP code you want to see the AST of: +
+ {% if astRun is defined %} +

Click on code part to see its AST

+
<?php
+{{ clickableNodesDump|raw }}
- {{ include('ast/_form.html.twig') }} +

Selected code is represented by following abstract syntax tree:

- {% if astRun is defined %} -
<?php {{ clickableNodesDump|raw }}
+
+
+
{{ simpleNodeDump }}
+
+
+ + {% if targetNodeClass %} +

In Mutator::canMutate() method you can use the following node to mutate it:

+
{{ targetNodeClass }}
+ {% endif %} + {% endif %} + +

+ {% if astRun is defined %} + Update the code and generate new AST: + {% else %} + Add PHP code to convert it to AST: + {% endif %} +

+ + {{ include('ast/_form.html.twig') }} -

Selected code is represented by following abstract syntax tree:

-
-
-
{{ simpleNodeDump }}
+
+
+

This AST explorer is highly insired by and uses Rector PHP's code (MIT license)

- {% endif %} +
+{% endblock %} + +{% block stylesheets %} + {{ parent() }} + {% endblock %} {% block javascripts %} + + + + + {{ encore_entry_script_tags('ast') }} {% endblock %} \ No newline at end of file diff --git a/app/templates/playground/create.html.twig b/app/templates/playground/create.html.twig index fcb0ad4..e4c2033 100644 --- a/app/templates/playground/create.html.twig +++ b/app/templates/playground/create.html.twig @@ -3,3 +3,7 @@ {% block body %} {{ include('playground/_form.html.twig') }} {% endblock %} + +{% block javascripts %} + {{ encore_entry_script_tags('app') }} +{% endblock %} \ No newline at end of file