Mercurial > hg > isophonics-drupal-site
diff vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | 5fb285c0d0e3 |
children |
line wrap: on
line diff
--- a/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php Tue Jul 10 15:07:59 2018 +0100 +++ b/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php Thu Feb 28 13:21:36 2019 +0000 @@ -9,7 +9,6 @@ use PhpParser\Node\Expr\AssignOp; use PhpParser\Node\Expr\BinaryOp; use PhpParser\Node\Expr\Cast; -use PhpParser\Node\Name; use PhpParser\Node\Scalar; use PhpParser\Node\Stmt; @@ -83,6 +82,7 @@ AssignOp\ShiftLeft::class => [160, 1], AssignOp\ShiftRight::class => [160, 1], AssignOp\Pow::class => [160, 1], + AssignOp\Coalesce::class => [160, 1], Expr\YieldFrom::class => [165, 1], Expr\Print_::class => [168, 1], BinaryOp\LogicalAnd::class => [170, -1], @@ -617,12 +617,14 @@ return $this->pFallback($fallbackNode); } - list($findToken, $extraLeft, $extraRight) = $this->insertionMap[$key]; + list($findToken, $beforeToken, $extraLeft, $extraRight) = $this->insertionMap[$key]; if (null !== $findToken) { - $subStartPos = $this->origTokens->findRight($pos, $findToken) + 1; + $subStartPos = $this->origTokens->findRight($pos, $findToken) + + (int) !$beforeToken; } else { $subStartPos = $pos; } + if (null === $extraLeft && null !== $extraRight) { // If inserting on the right only, skipping whitespace looks better $subStartPos = $this->origTokens->skipRightWhitespace($subStartPos); @@ -951,12 +953,15 @@ * @param string $append */ protected function safeAppend(string &$str, string $append) { - // $append must not be empty in this function if ($str === "") { $str = $append; return; } + if ($append === "") { + return; + } + if (!$this->labelCharMap[$append[0]] || !$this->labelCharMap[$str[\strlen($str) - 1]]) { $str .= $append; @@ -1152,7 +1157,7 @@ Expr\Assign::class, Expr\AssignRef::class, AssignOp\Plus::class, AssignOp\Minus::class, AssignOp\Mul::class, AssignOp\Div::class, AssignOp\Concat::class, AssignOp\Mod::class, AssignOp\BitwiseAnd::class, AssignOp\BitwiseOr::class, AssignOp\BitwiseXor::class, - AssignOp\ShiftLeft::class, AssignOp\ShiftRight::class, AssignOp\Pow::class, + AssignOp\ShiftLeft::class, AssignOp\ShiftRight::class, AssignOp\Pow::class, AssignOp\Coalesce::class ]; foreach ($assignOps as $assignOp) { $this->fixupMap[$assignOp] = [ @@ -1206,6 +1211,7 @@ 'Stmt_Function->returnType' => $stripColon, 'Stmt_If->else' => $stripLeft, 'Stmt_Namespace->name' => $stripLeft, + 'Stmt_Property->type' => $stripRight, 'Stmt_PropertyProperty->default' => $stripEquals, 'Stmt_Return->expr' => $stripBoth, 'Stmt_StaticVar->default' => $stripEquals, @@ -1223,28 +1229,29 @@ // TODO: "yield" where both key and value are inserted doesn't work $this->insertionMap = [ - 'Expr_ArrayDimFetch->dim' => ['[', null, null], - 'Expr_ArrayItem->key' => [null, null, ' => '], - 'Expr_Closure->returnType' => [')', ' : ', null], - 'Expr_Ternary->if' => ['?', ' ', ' '], - 'Expr_Yield->key' => [\T_YIELD, null, ' => '], - 'Expr_Yield->value' => [\T_YIELD, ' ', null], - 'Param->type' => [null, null, ' '], - 'Param->default' => [null, ' = ', null], - 'Stmt_Break->num' => [\T_BREAK, ' ', null], - 'Stmt_ClassMethod->returnType' => [')', ' : ', null], - 'Stmt_Class->extends' => [null, ' extends ', null], + 'Expr_ArrayDimFetch->dim' => ['[', false, null, null], + 'Expr_ArrayItem->key' => [null, false, null, ' => '], + 'Expr_Closure->returnType' => [')', false, ' : ', null], + 'Expr_Ternary->if' => ['?', false, ' ', ' '], + 'Expr_Yield->key' => [\T_YIELD, false, null, ' => '], + 'Expr_Yield->value' => [\T_YIELD, false, ' ', null], + 'Param->type' => [null, false, null, ' '], + 'Param->default' => [null, false, ' = ', null], + 'Stmt_Break->num' => [\T_BREAK, false, ' ', null], + 'Stmt_ClassMethod->returnType' => [')', false, ' : ', null], + 'Stmt_Class->extends' => [null, false, ' extends ', null], 'Expr_PrintableNewAnonClass->extends' => [null, ' extends ', null], - 'Stmt_Continue->num' => [\T_CONTINUE, ' ', null], - 'Stmt_Foreach->keyVar' => [\T_AS, null, ' => '], - 'Stmt_Function->returnType' => [')', ' : ', null], - 'Stmt_If->else' => [null, ' ', null], - 'Stmt_Namespace->name' => [\T_NAMESPACE, ' ', null], - 'Stmt_PropertyProperty->default' => [null, ' = ', null], - 'Stmt_Return->expr' => [\T_RETURN, ' ', null], - 'Stmt_StaticVar->default' => [null, ' = ', null], - //'Stmt_TraitUseAdaptation_Alias->newName' => [T_AS, ' ', null], // TODO - 'Stmt_TryCatch->finally' => [null, ' ', null], + 'Stmt_Continue->num' => [\T_CONTINUE, false, ' ', null], + 'Stmt_Foreach->keyVar' => [\T_AS, false, null, ' => '], + 'Stmt_Function->returnType' => [')', false, ' : ', null], + 'Stmt_If->else' => [null, false, ' ', null], + 'Stmt_Namespace->name' => [\T_NAMESPACE, false, ' ', null], + 'Stmt_Property->type' => [\T_VARIABLE, true, null, ' '], + 'Stmt_PropertyProperty->default' => [null, false, ' = ', null], + 'Stmt_Return->expr' => [\T_RETURN, false, ' ', null], + 'Stmt_StaticVar->default' => [null, false, ' = ', null], + //'Stmt_TraitUseAdaptation_Alias->newName' => [T_AS, false, ' ', null], // TODO + 'Stmt_TryCatch->finally' => [null, false, ' ', null], // 'Expr_Exit->expr': Complicated due to optional () // 'Stmt_Case->cond': Conversion from default to case