function PrettyPrinterAbstract::newOperandRequiresParens
Determines whether an expression used in "new" or "instanceof" requires parentheses.
Parameters
Node $node New or instanceof operand:
Return value
bool Whether parentheses are required
2 calls to PrettyPrinterAbstract::newOperandRequiresParens()
- PrettyPrinterAbstract::pFixup in vendor/
nikic/ php-parser/ lib/ PhpParser/ PrettyPrinterAbstract.php - Print node with fixups.
- Standard::pNewOperand in vendor/
nikic/ php-parser/ lib/ PhpParser/ PrettyPrinter/ Standard.php
File
-
vendor/
nikic/ php-parser/ lib/ PhpParser/ PrettyPrinterAbstract.php, line 1198
Class
Namespace
PhpParserCode
protected function newOperandRequiresParens(Node $node) : bool {
if ($node instanceof Node\Name || $node instanceof Expr\Variable) {
return false;
}
if ($node instanceof Expr\ArrayDimFetch || $node instanceof Expr\PropertyFetch || $node instanceof Expr\NullsafePropertyFetch) {
return $this->newOperandRequiresParens($node->var);
}
if ($node instanceof Expr\StaticPropertyFetch) {
return $this->newOperandRequiresParens($node->class);
}
return true;
}