Lines Matching refs:node
19 protected function pParam(Node\Param $node): string { argument
20 return $this->pAttrGroups($node->attrGroups, true)
21 . $this->pModifiers($node->flags)
22 . ($node->type ? $this->p($node->type) . ' ' : '')
23 . ($node->byRef ? '&' : '')
24 . ($node->variadic ? '...' : '')
25 . $this->p($node->var)
26 . ($node->default ? ' = ' . $this->p($node->default) : '')
27 . ($node->hooks ? ' {' . $this->pStmts($node->hooks) . $this->nl . '}' : '');
30 protected function pArg(Node\Arg $node): string { argument
31 return ($node->name ? $node->name->toString() . ': ' : '')
32 . ($node->byRef ? '&' : '') . ($node->unpack ? '...' : '')
33 . $this->p($node->value);
36 protected function pVariadicPlaceholder(Node\VariadicPlaceholder $node): string { argument
40 protected function pConst(Node\Const_ $node): string { argument
41 return $node->name . ' = ' . $this->p($node->value);
44 protected function pNullableType(Node\NullableType $node): string { argument
45 return '?' . $this->p($node->type);
48 protected function pUnionType(Node\UnionType $node): string { argument
50 foreach ($node->types as $typeNode) {
60 protected function pIntersectionType(Node\IntersectionType $node): string { argument
61 return $this->pImplode($node->types, '&');
64 protected function pIdentifier(Node\Identifier $node): string { argument
65 return $node->name;
68 protected function pVarLikeIdentifier(Node\VarLikeIdentifier $node): string { argument
69 return '$' . $node->name;
72 protected function pAttribute(Node\Attribute $node): string { argument
73 return $this->p($node->name)
74 . ($node->args ? '(' . $this->pCommaSeparated($node->args) . ')' : '');
77 protected function pAttributeGroup(Node\AttributeGroup $node): string { argument
78 return '#[' . $this->pCommaSeparated($node->attrs) . ']';
83 protected function pName(Name $node): string { argument
84 return $node->name;
87 protected function pName_FullyQualified(Name\FullyQualified $node): string { argument
88 return '\\' . $node->name;
91 protected function pName_Relative(Name\Relative $node): string { argument
92 return 'namespace\\' . $node->name;
97 protected function pScalar_MagicConst_Class(MagicConst\Class_ $node): string { argument
101 protected function pScalar_MagicConst_Dir(MagicConst\Dir $node): string { argument
105 protected function pScalar_MagicConst_File(MagicConst\File $node): string { argument
109 protected function pScalar_MagicConst_Function(MagicConst\Function_ $node): string { argument
113 protected function pScalar_MagicConst_Line(MagicConst\Line $node): string { argument
117 protected function pScalar_MagicConst_Method(MagicConst\Method $node): string { argument
121 protected function pScalar_MagicConst_Namespace(MagicConst\Namespace_ $node): string { argument
125 protected function pScalar_MagicConst_Trait(MagicConst\Trait_ $node): string { argument
129 protected function pScalar_MagicConst_Property(MagicConst\Property $node): string { argument
139 protected function pScalar_String(Scalar\String_ $node): string { argument
140 $kind = $node->getAttribute('kind', Scalar\String_::KIND_SINGLE_QUOTED);
143 $label = $node->getAttribute('docLabel');
144 if ($label && !$this->containsEndLabel($node->value, $label)) {
147 if ($node->value === '') {
152 if ($node->value[strlen($node->value) - 1] !== "\r") {
153 $value = $shouldIdent ? $this->indentString($node->value) : $node->value;
160 return $this->pSingleQuotedString($node->value);
162 $label = $node->getAttribute('docLabel');
163 $escaped = $this->escapeString($node->value, null);
175 return '"' . $this->escapeString($node->value, '"') . '"';
180 protected function pScalar_InterpolatedString(Scalar\InterpolatedString $node): string { argument
181 if ($node->getAttribute('kind') === Scalar\String_::KIND_HEREDOC) {
182 $label = $node->getAttribute('docLabel');
183 if ($label && !$this->encapsedContainsEndLabel($node->parts, $label)) {
185 if (count($node->parts) === 1
186 && $node->parts[0] instanceof Node\InterpolatedStringPart
187 && $node->parts[0]->value === ''
192 return "<<<$label$nl" . $this->pEncapsList($node->parts, null)
196 return '"' . $this->pEncapsList($node->parts, '"') . '"';
199 protected function pScalar_Int(Scalar\Int_ $node): string { argument
200 if ($node->value === -\PHP_INT_MAX - 1) {
206 $kind = $node->getAttribute('kind', Scalar\Int_::KIND_DEC);
208 return (string) $node->value;
211 if ($node->value < 0) {
213 $str = (string) -$node->value;
216 $str = (string) $node->value;
229 protected function pScalar_Float(Scalar\Float_ $node): string { argument
230 if (!is_finite($node->value)) {
231 if ($node->value === \INF) {
234 if ($node->value === -\INF) {
242 $stringValue = sprintf('%.16G', $node->value);
243 if ($node->value !== (float) $stringValue) {
244 $stringValue = sprintf('%.17G', $node->value);
258 … protected function pExpr_Assign(Expr\Assign $node, int $precedence, int $lhsPrecedence): string { argument
259 …return $this->pPrefixOp(Expr\Assign::class, $this->p($node->var) . ' = ', $node->expr, $precedence…
262 …protected function pExpr_AssignRef(Expr\AssignRef $node, int $precedence, int $lhsPrecedence): str… argument
263 …return $this->pPrefixOp(Expr\AssignRef::class, $this->p($node->var) . ' =& ', $node->expr, $preced…
266 …protected function pExpr_AssignOp_Plus(AssignOp\Plus $node, int $precedence, int $lhsPrecedence): … argument
267 …return $this->pPrefixOp(AssignOp\Plus::class, $this->p($node->var) . ' += ', $node->expr, $precede…
270 …protected function pExpr_AssignOp_Minus(AssignOp\Minus $node, int $precedence, int $lhsPrecedence)… argument
271 …return $this->pPrefixOp(AssignOp\Minus::class, $this->p($node->var) . ' -= ', $node->expr, $preced…
274 …protected function pExpr_AssignOp_Mul(AssignOp\Mul $node, int $precedence, int $lhsPrecedence): st… argument
275 …return $this->pPrefixOp(AssignOp\Mul::class, $this->p($node->var) . ' *= ', $node->expr, $preceden…
278 …protected function pExpr_AssignOp_Div(AssignOp\Div $node, int $precedence, int $lhsPrecedence): st… argument
279 …return $this->pPrefixOp(AssignOp\Div::class, $this->p($node->var) . ' /= ', $node->expr, $preceden…
282 …protected function pExpr_AssignOp_Concat(AssignOp\Concat $node, int $precedence, int $lhsPrecedenc… argument
283 …return $this->pPrefixOp(AssignOp\Concat::class, $this->p($node->var) . ' .= ', $node->expr, $prece…
286 …protected function pExpr_AssignOp_Mod(AssignOp\Mod $node, int $precedence, int $lhsPrecedence): st… argument
287 …return $this->pPrefixOp(AssignOp\Mod::class, $this->p($node->var) . ' %= ', $node->expr, $preceden…
290 …protected function pExpr_AssignOp_BitwiseAnd(AssignOp\BitwiseAnd $node, int $precedence, int $lhsP… argument
291 …return $this->pPrefixOp(AssignOp\BitwiseAnd::class, $this->p($node->var) . ' &= ', $node->expr, $p…
294 …protected function pExpr_AssignOp_BitwiseOr(AssignOp\BitwiseOr $node, int $precedence, int $lhsPre… argument
295 …return $this->pPrefixOp(AssignOp\BitwiseOr::class, $this->p($node->var) . ' |= ', $node->expr, $pr…
298 …protected function pExpr_AssignOp_BitwiseXor(AssignOp\BitwiseXor $node, int $precedence, int $lhsP… argument
299 …return $this->pPrefixOp(AssignOp\BitwiseXor::class, $this->p($node->var) . ' ^= ', $node->expr, $p…
302 …protected function pExpr_AssignOp_ShiftLeft(AssignOp\ShiftLeft $node, int $precedence, int $lhsPre… argument
303 …return $this->pPrefixOp(AssignOp\ShiftLeft::class, $this->p($node->var) . ' <<= ', $node->expr, $p…
306 …protected function pExpr_AssignOp_ShiftRight(AssignOp\ShiftRight $node, int $precedence, int $lhsP… argument
307 …return $this->pPrefixOp(AssignOp\ShiftRight::class, $this->p($node->var) . ' >>= ', $node->expr, $…
310 …protected function pExpr_AssignOp_Pow(AssignOp\Pow $node, int $precedence, int $lhsPrecedence): st… argument
311 …return $this->pPrefixOp(AssignOp\Pow::class, $this->p($node->var) . ' **= ', $node->expr, $precede…
314 …protected function pExpr_AssignOp_Coalesce(AssignOp\Coalesce $node, int $precedence, int $lhsPrece… argument
315 …return $this->pPrefixOp(AssignOp\Coalesce::class, $this->p($node->var) . ' ??= ', $node->expr, $pr…
320 …protected function pExpr_BinaryOp_Plus(BinaryOp\Plus $node, int $precedence, int $lhsPrecedence): … argument
321 …return $this->pInfixOp(BinaryOp\Plus::class, $node->left, ' + ', $node->right, $precedence, $lhsPr…
324 …protected function pExpr_BinaryOp_Minus(BinaryOp\Minus $node, int $precedence, int $lhsPrecedence)… argument
325 …return $this->pInfixOp(BinaryOp\Minus::class, $node->left, ' - ', $node->right, $precedence, $lhsP…
328 …protected function pExpr_BinaryOp_Mul(BinaryOp\Mul $node, int $precedence, int $lhsPrecedence): st… argument
329 …return $this->pInfixOp(BinaryOp\Mul::class, $node->left, ' * ', $node->right, $precedence, $lhsPre…
332 …protected function pExpr_BinaryOp_Div(BinaryOp\Div $node, int $precedence, int $lhsPrecedence): st… argument
333 …return $this->pInfixOp(BinaryOp\Div::class, $node->left, ' / ', $node->right, $precedence, $lhsPre…
336 …protected function pExpr_BinaryOp_Concat(BinaryOp\Concat $node, int $precedence, int $lhsPrecedenc… argument
337 …return $this->pInfixOp(BinaryOp\Concat::class, $node->left, ' . ', $node->right, $precedence, $lhs…
340 …protected function pExpr_BinaryOp_Mod(BinaryOp\Mod $node, int $precedence, int $lhsPrecedence): st… argument
341 …return $this->pInfixOp(BinaryOp\Mod::class, $node->left, ' % ', $node->right, $precedence, $lhsPre…
344 …protected function pExpr_BinaryOp_BooleanAnd(BinaryOp\BooleanAnd $node, int $precedence, int $lhsP… argument
345 …return $this->pInfixOp(BinaryOp\BooleanAnd::class, $node->left, ' && ', $node->right, $precedence,…
348 …protected function pExpr_BinaryOp_BooleanOr(BinaryOp\BooleanOr $node, int $precedence, int $lhsPre… argument
349 …return $this->pInfixOp(BinaryOp\BooleanOr::class, $node->left, ' || ', $node->right, $precedence, …
352 …protected function pExpr_BinaryOp_BitwiseAnd(BinaryOp\BitwiseAnd $node, int $precedence, int $lhsP… argument
353 …return $this->pInfixOp(BinaryOp\BitwiseAnd::class, $node->left, ' & ', $node->right, $precedence, …
356 …protected function pExpr_BinaryOp_BitwiseOr(BinaryOp\BitwiseOr $node, int $precedence, int $lhsPre… argument
357 …return $this->pInfixOp(BinaryOp\BitwiseOr::class, $node->left, ' | ', $node->right, $precedence, $…
360 …protected function pExpr_BinaryOp_BitwiseXor(BinaryOp\BitwiseXor $node, int $precedence, int $lhsP… argument
361 …return $this->pInfixOp(BinaryOp\BitwiseXor::class, $node->left, ' ^ ', $node->right, $precedence, …
364 …protected function pExpr_BinaryOp_ShiftLeft(BinaryOp\ShiftLeft $node, int $precedence, int $lhsPre… argument
365 …return $this->pInfixOp(BinaryOp\ShiftLeft::class, $node->left, ' << ', $node->right, $precedence, …
368 …protected function pExpr_BinaryOp_ShiftRight(BinaryOp\ShiftRight $node, int $precedence, int $lhsP… argument
369 …return $this->pInfixOp(BinaryOp\ShiftRight::class, $node->left, ' >> ', $node->right, $precedence,…
372 …protected function pExpr_BinaryOp_Pow(BinaryOp\Pow $node, int $precedence, int $lhsPrecedence): st… argument
373 …return $this->pInfixOp(BinaryOp\Pow::class, $node->left, ' ** ', $node->right, $precedence, $lhsPr…
376 …protected function pExpr_BinaryOp_LogicalAnd(BinaryOp\LogicalAnd $node, int $precedence, int $lhsP… argument
377 …return $this->pInfixOp(BinaryOp\LogicalAnd::class, $node->left, ' and ', $node->right, $precedence…
380 …protected function pExpr_BinaryOp_LogicalOr(BinaryOp\LogicalOr $node, int $precedence, int $lhsPre… argument
381 …return $this->pInfixOp(BinaryOp\LogicalOr::class, $node->left, ' or ', $node->right, $precedence, …
384 …protected function pExpr_BinaryOp_LogicalXor(BinaryOp\LogicalXor $node, int $precedence, int $lhsP… argument
385 …return $this->pInfixOp(BinaryOp\LogicalXor::class, $node->left, ' xor ', $node->right, $precedence…
388 …protected function pExpr_BinaryOp_Equal(BinaryOp\Equal $node, int $precedence, int $lhsPrecedence)… argument
389 …return $this->pInfixOp(BinaryOp\Equal::class, $node->left, ' == ', $node->right, $precedence, $lhs…
392 …protected function pExpr_BinaryOp_NotEqual(BinaryOp\NotEqual $node, int $precedence, int $lhsPrece… argument
393 …return $this->pInfixOp(BinaryOp\NotEqual::class, $node->left, ' != ', $node->right, $precedence, $…
396 …protected function pExpr_BinaryOp_Identical(BinaryOp\Identical $node, int $precedence, int $lhsPre… argument
397 …return $this->pInfixOp(BinaryOp\Identical::class, $node->left, ' === ', $node->right, $precedence,…
400 …protected function pExpr_BinaryOp_NotIdentical(BinaryOp\NotIdentical $node, int $precedence, int $… argument
401 …return $this->pInfixOp(BinaryOp\NotIdentical::class, $node->left, ' !== ', $node->right, $preceden…
404 …protected function pExpr_BinaryOp_Spaceship(BinaryOp\Spaceship $node, int $precedence, int $lhsPre… argument
405 …return $this->pInfixOp(BinaryOp\Spaceship::class, $node->left, ' <=> ', $node->right, $precedence,…
408 …protected function pExpr_BinaryOp_Greater(BinaryOp\Greater $node, int $precedence, int $lhsPrecede… argument
409 …return $this->pInfixOp(BinaryOp\Greater::class, $node->left, ' > ', $node->right, $precedence, $lh…
412 …protected function pExpr_BinaryOp_GreaterOrEqual(BinaryOp\GreaterOrEqual $node, int $precedence, i… argument
413 …return $this->pInfixOp(BinaryOp\GreaterOrEqual::class, $node->left, ' >= ', $node->right, $precede…
416 …protected function pExpr_BinaryOp_Smaller(BinaryOp\Smaller $node, int $precedence, int $lhsPrecede… argument
417 …return $this->pInfixOp(BinaryOp\Smaller::class, $node->left, ' < ', $node->right, $precedence, $lh…
420 …protected function pExpr_BinaryOp_SmallerOrEqual(BinaryOp\SmallerOrEqual $node, int $precedence, i… argument
421 …return $this->pInfixOp(BinaryOp\SmallerOrEqual::class, $node->left, ' <= ', $node->right, $precede…
424 …protected function pExpr_BinaryOp_Coalesce(BinaryOp\Coalesce $node, int $precedence, int $lhsPrece… argument
425 …return $this->pInfixOp(BinaryOp\Coalesce::class, $node->left, ' ?? ', $node->right, $precedence, $…
428 …protected function pExpr_Instanceof(Expr\Instanceof_ $node, int $precedence, int $lhsPrecedence): … argument
430 Expr\Instanceof_::class, $node->expr,
431 ' instanceof ' . $this->pNewOperand($node->class),
437 …protected function pExpr_BooleanNot(Expr\BooleanNot $node, int $precedence, int $lhsPrecedence): s… argument
438 … return $this->pPrefixOp(Expr\BooleanNot::class, '!', $node->expr, $precedence, $lhsPrecedence);
441 …protected function pExpr_BitwiseNot(Expr\BitwiseNot $node, int $precedence, int $lhsPrecedence): s… argument
442 … return $this->pPrefixOp(Expr\BitwiseNot::class, '~', $node->expr, $precedence, $lhsPrecedence);
445 …protected function pExpr_UnaryMinus(Expr\UnaryMinus $node, int $precedence, int $lhsPrecedence): s… argument
446 … return $this->pPrefixOp(Expr\UnaryMinus::class, '-', $node->expr, $precedence, $lhsPrecedence);
449 …protected function pExpr_UnaryPlus(Expr\UnaryPlus $node, int $precedence, int $lhsPrecedence): str… argument
450 … return $this->pPrefixOp(Expr\UnaryPlus::class, '+', $node->expr, $precedence, $lhsPrecedence);
453 protected function pExpr_PreInc(Expr\PreInc $node): string { argument
454 return '++' . $this->p($node->var);
457 protected function pExpr_PreDec(Expr\PreDec $node): string { argument
458 return '--' . $this->p($node->var);
461 protected function pExpr_PostInc(Expr\PostInc $node): string { argument
462 return $this->p($node->var) . '++';
465 protected function pExpr_PostDec(Expr\PostDec $node): string { argument
466 return $this->p($node->var) . '--';
469 …protected function pExpr_ErrorSuppress(Expr\ErrorSuppress $node, int $precedence, int $lhsPreceden… argument
470 … return $this->pPrefixOp(Expr\ErrorSuppress::class, '@', $node->expr, $precedence, $lhsPrecedence);
473 …protected function pExpr_YieldFrom(Expr\YieldFrom $node, int $precedence, int $lhsPrecedence): str… argument
474 …return $this->pPrefixOp(Expr\YieldFrom::class, 'yield from ', $node->expr, $precedence, $lhsPreced…
477 protected function pExpr_Print(Expr\Print_ $node, int $precedence, int $lhsPrecedence): string { argument
478 … return $this->pPrefixOp(Expr\Print_::class, 'print ', $node->expr, $precedence, $lhsPrecedence);
483 … protected function pExpr_Cast_Int(Cast\Int_ $node, int $precedence, int $lhsPrecedence): string { argument
484 … return $this->pPrefixOp(Cast\Int_::class, '(int) ', $node->expr, $precedence, $lhsPrecedence);
487 …protected function pExpr_Cast_Double(Cast\Double $node, int $precedence, int $lhsPrecedence): stri… argument
488 $kind = $node->getAttribute('kind', Cast\Double::KIND_DOUBLE);
497 …return $this->pPrefixOp(Cast\Double::class, $cast . ' ', $node->expr, $precedence, $lhsPrecedence);
500 …protected function pExpr_Cast_String(Cast\String_ $node, int $precedence, int $lhsPrecedence): str… argument
501 …return $this->pPrefixOp(Cast\String_::class, '(string) ', $node->expr, $precedence, $lhsPrecedence…
504 …protected function pExpr_Cast_Array(Cast\Array_ $node, int $precedence, int $lhsPrecedence): strin… argument
505 … return $this->pPrefixOp(Cast\Array_::class, '(array) ', $node->expr, $precedence, $lhsPrecedence);
508 …protected function pExpr_Cast_Object(Cast\Object_ $node, int $precedence, int $lhsPrecedence): str… argument
509 …return $this->pPrefixOp(Cast\Object_::class, '(object) ', $node->expr, $precedence, $lhsPrecedence…
512 …protected function pExpr_Cast_Bool(Cast\Bool_ $node, int $precedence, int $lhsPrecedence): string { argument
513 … return $this->pPrefixOp(Cast\Bool_::class, '(bool) ', $node->expr, $precedence, $lhsPrecedence);
516 …protected function pExpr_Cast_Unset(Cast\Unset_ $node, int $precedence, int $lhsPrecedence): strin… argument
517 … return $this->pPrefixOp(Cast\Unset_::class, '(unset) ', $node->expr, $precedence, $lhsPrecedence);
522 protected function pExpr_FuncCall(Expr\FuncCall $node): string { argument
523 return $this->pCallLhs($node->name)
524 . '(' . $this->pMaybeMultiline($node->args) . ')';
527 protected function pExpr_MethodCall(Expr\MethodCall $node): string { argument
528 return $this->pDereferenceLhs($node->var) . '->' . $this->pObjectProperty($node->name)
529 . '(' . $this->pMaybeMultiline($node->args) . ')';
532 protected function pExpr_NullsafeMethodCall(Expr\NullsafeMethodCall $node): string { argument
533 return $this->pDereferenceLhs($node->var) . '?->' . $this->pObjectProperty($node->name)
534 . '(' . $this->pMaybeMultiline($node->args) . ')';
537 protected function pExpr_StaticCall(Expr\StaticCall $node): string { argument
538 return $this->pStaticDereferenceLhs($node->class) . '::'
539 . ($node->name instanceof Expr
540 ? ($node->name instanceof Expr\Variable
541 ? $this->p($node->name)
542 : '{' . $this->p($node->name) . '}')
543 : $node->name)
544 . '(' . $this->pMaybeMultiline($node->args) . ')';
547 protected function pExpr_Empty(Expr\Empty_ $node): string { argument
548 return 'empty(' . $this->p($node->expr) . ')';
551 protected function pExpr_Isset(Expr\Isset_ $node): string { argument
552 return 'isset(' . $this->pCommaSeparated($node->vars) . ')';
555 protected function pExpr_Eval(Expr\Eval_ $node): string { argument
556 return 'eval(' . $this->p($node->expr) . ')';
559 …protected function pExpr_Include(Expr\Include_ $node, int $precedence, int $lhsPrecedence): string… argument
567 …return $this->pPrefixOp(Expr\Include_::class, $map[$node->type] . ' ', $node->expr, $precedence, $…
570 protected function pExpr_List(Expr\List_ $node): string { argument
571 $syntax = $node->getAttribute('kind',
574 return '[' . $this->pMaybeMultiline($node->items, true) . ']';
576 return 'list(' . $this->pMaybeMultiline($node->items, true) . ')';
582 protected function pExpr_Error(Expr\Error $node): string { argument
586 protected function pExpr_Variable(Expr\Variable $node): string { argument
587 if ($node->name instanceof Expr) {
588 return '${' . $this->p($node->name) . '}';
590 return '$' . $node->name;
594 protected function pExpr_Array(Expr\Array_ $node): string { argument
595 $syntax = $node->getAttribute('kind',
598 return '[' . $this->pMaybeMultiline($node->items, true) . ']';
600 return 'array(' . $this->pMaybeMultiline($node->items, true) . ')';
604 protected function pKey(?Node $node): string { argument
605 if ($node === null) {
616 return $this->p($node, self::MAX_PRECEDENCE, $yieldPrecedence) . ' => ';
619 protected function pArrayItem(Node\ArrayItem $node): string { argument
620 return $this->pKey($node->key)
621 . ($node->byRef ? '&' : '')
622 . ($node->unpack ? '...' : '')
623 . $this->p($node->value);
626 protected function pExpr_ArrayDimFetch(Expr\ArrayDimFetch $node): string { argument
627 return $this->pDereferenceLhs($node->var)
628 . '[' . (null !== $node->dim ? $this->p($node->dim) : '') . ']';
631 protected function pExpr_ConstFetch(Expr\ConstFetch $node): string { argument
632 return $this->p($node->name);
635 protected function pExpr_ClassConstFetch(Expr\ClassConstFetch $node): string { argument
636 … return $this->pStaticDereferenceLhs($node->class) . '::' . $this->pObjectProperty($node->name);
639 protected function pExpr_PropertyFetch(Expr\PropertyFetch $node): string { argument
640 return $this->pDereferenceLhs($node->var) . '->' . $this->pObjectProperty($node->name);
643 protected function pExpr_NullsafePropertyFetch(Expr\NullsafePropertyFetch $node): string { argument
644 return $this->pDereferenceLhs($node->var) . '?->' . $this->pObjectProperty($node->name);
647 protected function pExpr_StaticPropertyFetch(Expr\StaticPropertyFetch $node): string { argument
648 … return $this->pStaticDereferenceLhs($node->class) . '::$' . $this->pObjectProperty($node->name);
651 protected function pExpr_ShellExec(Expr\ShellExec $node): string { argument
652 return '`' . $this->pEncapsList($node->parts, '`') . '`';
655 protected function pExpr_Closure(Expr\Closure $node): string { argument
656 return $this->pAttrGroups($node->attrGroups, true)
657 . $this->pStatic($node->static)
658 . 'function ' . ($node->byRef ? '&' : '')
659 …. '(' . $this->pMaybeMultiline($node->params, $this->phpVersion->supportsTrailingCommaInParamList(…
660 . (!empty($node->uses) ? ' use (' . $this->pCommaSeparated($node->uses) . ')' : '')
661 . (null !== $node->returnType ? ': ' . $this->p($node->returnType) : '')
662 . ' {' . $this->pStmts($node->stmts) . $this->nl . '}';
665 protected function pExpr_Match(Expr\Match_ $node): string { argument
666 return 'match (' . $this->p($node->cond) . ') {'
667 . $this->pCommaSeparatedMultiline($node->arms, true)
672 protected function pMatchArm(Node\MatchArm $node): string { argument
674 if ($node->conds) {
675 for ($i = 0, $c = \count($node->conds); $i + 1 < $c; $i++) {
676 $result .= $this->p($node->conds[$i]) . ', ';
678 $result .= $this->pKey($node->conds[$i]);
682 return $result . $this->p($node->body);
685 …protected function pExpr_ArrowFunction(Expr\ArrowFunction $node, int $precedence, int $lhsPreceden… argument
688 $this->pAttrGroups($node->attrGroups, true)
689 . $this->pStatic($node->static)
690 . 'fn' . ($node->byRef ? '&' : '')
691 …. '(' . $this->pMaybeMultiline($node->params, $this->phpVersion->supportsTrailingCommaInParamList(…
692 . (null !== $node->returnType ? ': ' . $this->p($node->returnType) : '')
694 $node->expr, $precedence, $lhsPrecedence);
697 protected function pClosureUse(Node\ClosureUse $node): string { argument
698 return ($node->byRef ? '&' : '') . $this->p($node->var);
701 protected function pExpr_New(Expr\New_ $node): string { argument
702 if ($node->class instanceof Stmt\Class_) {
703 $args = $node->args ? '(' . $this->pMaybeMultiline($node->args) . ')' : '';
704 return 'new ' . $this->pClassCommon($node->class, $args);
706 return 'new ' . $this->pNewOperand($node->class)
707 . '(' . $this->pMaybeMultiline($node->args) . ')';
710 protected function pExpr_Clone(Expr\Clone_ $node, int $precedence, int $lhsPrecedence): string { argument
711 … return $this->pPrefixOp(Expr\Clone_::class, 'clone ', $node->expr, $precedence, $lhsPrecedence);
714 …protected function pExpr_Ternary(Expr\Ternary $node, int $precedence, int $lhsPrecedence): string { argument
718 …$node->cond, ' ?' . (null !== $node->if ? ' ' . $this->p($node->if) . ' ' : '') . ': ', $node->els…
723 protected function pExpr_Exit(Expr\Exit_ $node): string { argument
724 $kind = $node->getAttribute('kind', Expr\Exit_::KIND_DIE);
726 . (null !== $node->expr ? '(' . $this->p($node->expr) . ')' : '');
729 protected function pExpr_Throw(Expr\Throw_ $node, int $precedence, int $lhsPrecedence): string { argument
730 … return $this->pPrefixOp(Expr\Throw_::class, 'throw ', $node->expr, $precedence, $lhsPrecedence);
733 protected function pExpr_Yield(Expr\Yield_ $node, int $precedence, int $lhsPrecedence): string { argument
734 if ($node->value === null) {
739 return '(yield ' . $this->pKey($node->key) . $this->p($node->value) . ')';
742 Expr\Yield_::class, 'yield ' . $this->pKey($node->key),
743 $node->value, $precedence, $lhsPrecedence);
749 protected function pStmt_Namespace(Stmt\Namespace_ $node): string { argument
751 return 'namespace ' . $this->p($node->name) . ';'
752 . $this->nl . $this->pStmts($node->stmts, false);
754 return 'namespace' . (null !== $node->name ? ' ' . $this->p($node->name) : '')
755 . ' {' . $this->pStmts($node->stmts) . $this->nl . '}';
759 protected function pStmt_Use(Stmt\Use_ $node): string { argument
760 return 'use ' . $this->pUseType($node->type)
761 . $this->pCommaSeparated($node->uses) . ';';
764 protected function pStmt_GroupUse(Stmt\GroupUse $node): string { argument
765 return 'use ' . $this->pUseType($node->type) . $this->pName($node->prefix)
766 . '\{' . $this->pCommaSeparated($node->uses) . '};';
769 protected function pUseItem(Node\UseItem $node): string { argument
770 return $this->pUseType($node->type) . $this->p($node->name)
771 . (null !== $node->alias ? ' as ' . $node->alias : '');
779 protected function pStmt_Interface(Stmt\Interface_ $node): string { argument
780 return $this->pAttrGroups($node->attrGroups)
781 . 'interface ' . $node->name
782 . (!empty($node->extends) ? ' extends ' . $this->pCommaSeparated($node->extends) : '')
783 . $this->nl . '{' . $this->pStmts($node->stmts) . $this->nl . '}';
786 protected function pStmt_Enum(Stmt\Enum_ $node): string { argument
787 return $this->pAttrGroups($node->attrGroups)
788 . 'enum ' . $node->name
789 . ($node->scalarType ? ' : ' . $this->p($node->scalarType) : '')
790 … . (!empty($node->implements) ? ' implements ' . $this->pCommaSeparated($node->implements) : '')
791 . $this->nl . '{' . $this->pStmts($node->stmts) . $this->nl . '}';
794 protected function pStmt_Class(Stmt\Class_ $node): string { argument
795 return $this->pClassCommon($node, ' ' . $node->name);
798 protected function pStmt_Trait(Stmt\Trait_ $node): string { argument
799 return $this->pAttrGroups($node->attrGroups)
800 . 'trait ' . $node->name
801 . $this->nl . '{' . $this->pStmts($node->stmts) . $this->nl . '}';
804 protected function pStmt_EnumCase(Stmt\EnumCase $node): string { argument
805 return $this->pAttrGroups($node->attrGroups)
806 . 'case ' . $node->name
807 . ($node->expr ? ' = ' . $this->p($node->expr) : '')
811 protected function pStmt_TraitUse(Stmt\TraitUse $node): string { argument
812 return 'use ' . $this->pCommaSeparated($node->traits)
813 . (empty($node->adaptations)
815 : ' {' . $this->pStmts($node->adaptations) . $this->nl . '}');
818 …protected function pStmt_TraitUseAdaptation_Precedence(Stmt\TraitUseAdaptation\Precedence $node): … argument
819 return $this->p($node->trait) . '::' . $node->method
820 . ' insteadof ' . $this->pCommaSeparated($node->insteadof) . ';';
823 protected function pStmt_TraitUseAdaptation_Alias(Stmt\TraitUseAdaptation\Alias $node): string { argument
824 return (null !== $node->trait ? $this->p($node->trait) . '::' : '')
825 . $node->method . ' as'
826 … . (null !== $node->newModifier ? ' ' . rtrim($this->pModifiers($node->newModifier), ' ') : '')
827 . (null !== $node->newName ? ' ' . $node->newName : '')
831 protected function pStmt_Property(Stmt\Property $node): string { argument
832 return $this->pAttrGroups($node->attrGroups)
833 . (0 === $node->flags ? 'var ' : $this->pModifiers($node->flags))
834 . ($node->type ? $this->p($node->type) . ' ' : '')
835 . $this->pCommaSeparated($node->props)
836 . ($node->hooks ? ' {' . $this->pStmts($node->hooks) . $this->nl . '}' : ';');
839 protected function pPropertyItem(Node\PropertyItem $node): string { argument
840 return '$' . $node->name
841 . (null !== $node->default ? ' = ' . $this->p($node->default) : '');
844 protected function pPropertyHook(Node\PropertyHook $node): string { argument
845 return $this->pAttrGroups($node->attrGroups)
846 . $this->pModifiers($node->flags)
847 . ($node->byRef ? '&' : '') . $node->name
848 …. ($node->params ? '(' . $this->pMaybeMultiline($node->params, $this->phpVersion->supportsTrailing…
849 . (\is_array($node->body) ? ' {' . $this->pStmts($node->body) . $this->nl . '}'
850 : ($node->body !== null ? ' => ' . $this->p($node->body) : '') . ';');
853 protected function pStmt_ClassMethod(Stmt\ClassMethod $node): string { argument
854 return $this->pAttrGroups($node->attrGroups)
855 . $this->pModifiers($node->flags)
856 . 'function ' . ($node->byRef ? '&' : '') . $node->name
857 …. '(' . $this->pMaybeMultiline($node->params, $this->phpVersion->supportsTrailingCommaInParamList(…
858 . (null !== $node->returnType ? ': ' . $this->p($node->returnType) : '')
859 . (null !== $node->stmts
860 ? $this->nl . '{' . $this->pStmts($node->stmts) . $this->nl . '}'
864 protected function pStmt_ClassConst(Stmt\ClassConst $node): string { argument
865 return $this->pAttrGroups($node->attrGroups)
866 . $this->pModifiers($node->flags)
868 . (null !== $node->type ? $this->p($node->type) . ' ' : '')
869 . $this->pCommaSeparated($node->consts) . ';';
872 protected function pStmt_Function(Stmt\Function_ $node): string { argument
873 return $this->pAttrGroups($node->attrGroups)
874 . 'function ' . ($node->byRef ? '&' : '') . $node->name
875 …. '(' . $this->pMaybeMultiline($node->params, $this->phpVersion->supportsTrailingCommaInParamList(…
876 . (null !== $node->returnType ? ': ' . $this->p($node->returnType) : '')
877 . $this->nl . '{' . $this->pStmts($node->stmts) . $this->nl . '}';
880 protected function pStmt_Const(Stmt\Const_ $node): string { argument
881 return 'const ' . $this->pCommaSeparated($node->consts) . ';';
884 protected function pStmt_Declare(Stmt\Declare_ $node): string { argument
885 return 'declare (' . $this->pCommaSeparated($node->declares) . ')'
886 . (null !== $node->stmts ? ' {' . $this->pStmts($node->stmts) . $this->nl . '}' : ';');
889 protected function pDeclareItem(Node\DeclareItem $node): string { argument
890 return $node->key . '=' . $this->p($node->value);
895 protected function pStmt_If(Stmt\If_ $node): string { argument
896 return 'if (' . $this->p($node->cond) . ') {'
897 . $this->pStmts($node->stmts) . $this->nl . '}'
898 . ($node->elseifs ? ' ' . $this->pImplode($node->elseifs, ' ') : '')
899 . (null !== $node->else ? ' ' . $this->p($node->else) : '');
902 protected function pStmt_ElseIf(Stmt\ElseIf_ $node): string { argument
903 return 'elseif (' . $this->p($node->cond) . ') {'
904 . $this->pStmts($node->stmts) . $this->nl . '}';
907 protected function pStmt_Else(Stmt\Else_ $node): string { argument
908 if (\count($node->stmts) === 1 && $node->stmts[0] instanceof Stmt\If_) {
910 return 'else ' . $this->p($node->stmts[0]);
912 return 'else {' . $this->pStmts($node->stmts) . $this->nl . '}';
915 protected function pStmt_For(Stmt\For_ $node): string { argument
917 . $this->pCommaSeparated($node->init) . ';' . (!empty($node->cond) ? ' ' : '')
918 . $this->pCommaSeparated($node->cond) . ';' . (!empty($node->loop) ? ' ' : '')
919 . $this->pCommaSeparated($node->loop)
920 . ') {' . $this->pStmts($node->stmts) . $this->nl . '}';
923 protected function pStmt_Foreach(Stmt\Foreach_ $node): string { argument
924 return 'foreach (' . $this->p($node->expr) . ' as '
925 . (null !== $node->keyVar ? $this->p($node->keyVar) . ' => ' : '')
926 . ($node->byRef ? '&' : '') . $this->p($node->valueVar) . ') {'
927 . $this->pStmts($node->stmts) . $this->nl . '}';
930 protected function pStmt_While(Stmt\While_ $node): string { argument
931 return 'while (' . $this->p($node->cond) . ') {'
932 . $this->pStmts($node->stmts) . $this->nl . '}';
935 protected function pStmt_Do(Stmt\Do_ $node): string { argument
936 return 'do {' . $this->pStmts($node->stmts) . $this->nl
937 . '} while (' . $this->p($node->cond) . ');';
940 protected function pStmt_Switch(Stmt\Switch_ $node): string { argument
941 return 'switch (' . $this->p($node->cond) . ') {'
942 . $this->pStmts($node->cases) . $this->nl . '}';
945 protected function pStmt_Case(Stmt\Case_ $node): string { argument
946 return (null !== $node->cond ? 'case ' . $this->p($node->cond) : 'default') . ':'
947 . $this->pStmts($node->stmts);
950 protected function pStmt_TryCatch(Stmt\TryCatch $node): string { argument
951 return 'try {' . $this->pStmts($node->stmts) . $this->nl . '}'
952 . ($node->catches ? ' ' . $this->pImplode($node->catches, ' ') : '')
953 . ($node->finally !== null ? ' ' . $this->p($node->finally) : '');
956 protected function pStmt_Catch(Stmt\Catch_ $node): string { argument
957 return 'catch (' . $this->pImplode($node->types, '|')
958 . ($node->var !== null ? ' ' . $this->p($node->var) : '')
959 . ') {' . $this->pStmts($node->stmts) . $this->nl . '}';
962 protected function pStmt_Finally(Stmt\Finally_ $node): string { argument
963 return 'finally {' . $this->pStmts($node->stmts) . $this->nl . '}';
966 protected function pStmt_Break(Stmt\Break_ $node): string { argument
967 return 'break' . ($node->num !== null ? ' ' . $this->p($node->num) : '') . ';';
970 protected function pStmt_Continue(Stmt\Continue_ $node): string { argument
971 return 'continue' . ($node->num !== null ? ' ' . $this->p($node->num) : '') . ';';
974 protected function pStmt_Return(Stmt\Return_ $node): string { argument
975 return 'return' . (null !== $node->expr ? ' ' . $this->p($node->expr) : '') . ';';
978 protected function pStmt_Label(Stmt\Label $node): string { argument
979 return $node->name . ':';
982 protected function pStmt_Goto(Stmt\Goto_ $node): string { argument
983 return 'goto ' . $node->name . ';';
988 protected function pStmt_Expression(Stmt\Expression $node): string { argument
989 return $this->p($node->expr) . ';';
992 protected function pStmt_Echo(Stmt\Echo_ $node): string { argument
993 return 'echo ' . $this->pCommaSeparated($node->exprs) . ';';
996 protected function pStmt_Static(Stmt\Static_ $node): string { argument
997 return 'static ' . $this->pCommaSeparated($node->vars) . ';';
1000 protected function pStmt_Global(Stmt\Global_ $node): string { argument
1001 return 'global ' . $this->pCommaSeparated($node->vars) . ';';
1004 protected function pStaticVar(Node\StaticVar $node): string { argument
1005 return $this->p($node->var)
1006 . (null !== $node->default ? ' = ' . $this->p($node->default) : '');
1009 protected function pStmt_Unset(Stmt\Unset_ $node): string { argument
1010 return 'unset(' . $this->pCommaSeparated($node->vars) . ');';
1013 protected function pStmt_InlineHTML(Stmt\InlineHTML $node): string { argument
1014 $newline = $node->getAttribute('hasLeadingNewline', true) ? $this->newline : '';
1015 return '?>' . $newline . $node->value . '<?php ';
1018 protected function pStmt_HaltCompiler(Stmt\HaltCompiler $node): string { argument
1019 return '__halt_compiler();' . $node->remaining;
1022 protected function pStmt_Nop(Stmt\Nop $node): string { argument
1026 protected function pStmt_Block(Stmt\Block $node): string { argument
1027 return '{' . $this->pStmts($node->stmts) . $this->nl . '}';
1032 protected function pClassCommon(Stmt\Class_ $node, string $afterClassToken): string { argument
1033 return $this->pAttrGroups($node->attrGroups, $node->name === null)
1034 . $this->pModifiers($node->flags)
1036 . (null !== $node->extends ? ' extends ' . $this->p($node->extends) : '')
1037 … . (!empty($node->implements) ? ' implements ' . $this->pCommaSeparated($node->implements) : '')
1038 . $this->nl . '{' . $this->pStmts($node->stmts) . $this->nl . '}';
1041 protected function pObjectProperty(Node $node): string { argument
1042 if ($node instanceof Expr) {
1043 return '{' . $this->p($node) . '}';
1045 assert($node instanceof Node\Identifier);
1046 return $node->name;
1129 protected function pDereferenceLhs(Node $node): string { argument
1130 if (!$this->dereferenceLhsRequiresParens($node)) {
1131 return $this->p($node);
1133 return '(' . $this->p($node) . ')';
1137 protected function pStaticDereferenceLhs(Node $node): string { argument
1138 if (!$this->staticDereferenceLhsRequiresParens($node)) {
1139 return $this->p($node);
1141 return '(' . $this->p($node) . ')';
1145 protected function pCallLhs(Node $node): string { argument
1146 if (!$this->callLhsRequiresParens($node)) {
1147 return $this->p($node);
1149 return '(' . $this->p($node) . ')';
1153 protected function pNewOperand(Node $node): string { argument
1154 if (!$this->newOperandRequiresParens($node)) {
1155 return $this->p($node);
1157 return '(' . $this->p($node) . ')';
1165 foreach ($nodes as $node) {
1166 if ($node && $node->getComments()) {
1186 foreach ($nodes as $node) {
1187 $result .= $this->p($node) . $sep;