function PrettyPrinterAbstract::initializeRemovalMap
Lazily initializes the removal map.
The removal map is used to determine which additional tokens should be removed when a certain node is replaced by null.
1 call to PrettyPrinterAbstract::initializeRemovalMap()
- PrettyPrinterAbstract::printFormatPreserving in vendor/
nikic/ php-parser/ lib/ PhpParser/ PrettyPrinterAbstract.php - Perform a format-preserving pretty print of an AST.
File
-
vendor/
nikic/ php-parser/ lib/ PhpParser/ PrettyPrinterAbstract.php, line 1406
Class
Namespace
PhpParserCode
protected function initializeRemovalMap() : void {
if (isset($this->removalMap)) {
return;
}
$stripBoth = [
'left' => \T_WHITESPACE,
'right' => \T_WHITESPACE,
];
$stripLeft = [
'left' => \T_WHITESPACE,
];
$stripRight = [
'right' => \T_WHITESPACE,
];
$stripDoubleArrow = [
'right' => \T_DOUBLE_ARROW,
];
$stripColon = [
'left' => ':',
];
$stripEquals = [
'left' => '=',
];
$this->removalMap = [
'Expr_ArrayDimFetch->dim' => $stripBoth,
'ArrayItem->key' => $stripDoubleArrow,
'Expr_ArrowFunction->returnType' => $stripColon,
'Expr_Closure->returnType' => $stripColon,
'Expr_Exit->expr' => $stripBoth,
'Expr_Ternary->if' => $stripBoth,
'Expr_Yield->key' => $stripDoubleArrow,
'Expr_Yield->value' => $stripBoth,
'Param->type' => $stripRight,
'Param->default' => $stripEquals,
'Stmt_Break->num' => $stripBoth,
'Stmt_Catch->var' => $stripLeft,
'Stmt_ClassConst->type' => $stripRight,
'Stmt_ClassMethod->returnType' => $stripColon,
'Stmt_Class->extends' => [
'left' => \T_EXTENDS,
],
'Stmt_Enum->scalarType' => $stripColon,
'Stmt_EnumCase->expr' => $stripEquals,
'Expr_PrintableNewAnonClass->extends' => [
'left' => \T_EXTENDS,
],
'Stmt_Continue->num' => $stripBoth,
'Stmt_Foreach->keyVar' => $stripDoubleArrow,
'Stmt_Function->returnType' => $stripColon,
'Stmt_If->else' => $stripLeft,
'Stmt_Namespace->name' => $stripLeft,
'Stmt_Property->type' => $stripRight,
'PropertyItem->default' => $stripEquals,
'Stmt_Return->expr' => $stripBoth,
'Stmt_StaticVar->default' => $stripEquals,
'Stmt_TraitUseAdaptation_Alias->newName' => $stripLeft,
'Stmt_TryCatch->finally' => $stripLeft,
];
}