mirror of
https://github.com/nikic/PHP-Parser.git
synced 2025-01-17 15:18:17 +01:00
Fix formatting preservation for match
This commit is contained in:
parent
c585a2d766
commit
a772853307
@ -826,8 +826,10 @@ abstract class PrettyPrinterAbstract {
|
|||||||
|
|
||||||
// We go multiline if the original code was multiline,
|
// We go multiline if the original code was multiline,
|
||||||
// or if it's an array item with a comment above it.
|
// or if it's an array item with a comment above it.
|
||||||
|
// Match always uses multiline formatting.
|
||||||
if ($insertStr === ', ' &&
|
if ($insertStr === ', ' &&
|
||||||
($this->isMultiline($origNodes) || $arrItem->getComments())
|
($this->isMultiline($origNodes) || $arrItem->getComments() ||
|
||||||
|
$parentNodeClass === Expr\Match_::class)
|
||||||
) {
|
) {
|
||||||
$insertStr = ',';
|
$insertStr = ',';
|
||||||
$insertNewline = true;
|
$insertNewline = true;
|
||||||
@ -1378,7 +1380,7 @@ abstract class PrettyPrinterAbstract {
|
|||||||
Stmt\Global_::class . '->vars' => ', ',
|
Stmt\Global_::class . '->vars' => ', ',
|
||||||
Stmt\GroupUse::class . '->uses' => ', ',
|
Stmt\GroupUse::class . '->uses' => ', ',
|
||||||
Stmt\Interface_::class . '->extends' => ', ',
|
Stmt\Interface_::class . '->extends' => ', ',
|
||||||
//Expr\Match_::class . '->arms' => ', ',
|
Expr\Match_::class . '->arms' => ', ',
|
||||||
Stmt\Property::class . '->props' => ', ',
|
Stmt\Property::class . '->props' => ', ',
|
||||||
Stmt\StaticVar::class . '->vars' => ', ',
|
Stmt\StaticVar::class . '->vars' => ', ',
|
||||||
Stmt\TraitUse::class . '->traits' => ', ',
|
Stmt\TraitUse::class . '->traits' => ', ',
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
Matches
|
Matches
|
||||||
-----
|
-----
|
||||||
<?php
|
<?php
|
||||||
$value = match (1) {
|
$value = match (1)
|
||||||
|
{
|
||||||
1
|
1
|
||||||
=>
|
=>
|
||||||
'one'
|
'one'
|
||||||
@ -10,11 +11,12 @@ $value = match (1) {
|
|||||||
$stmts[0]->expr->expr->arms[] = new Node\MatchArm(null, new Scalar\String_('two'));
|
$stmts[0]->expr->expr->arms[] = new Node\MatchArm(null, new Scalar\String_('two'));
|
||||||
-----
|
-----
|
||||||
<?php
|
<?php
|
||||||
$value = match (1) {
|
$value = match (1)
|
||||||
|
{
|
||||||
1
|
1
|
||||||
=>
|
=>
|
||||||
'one',
|
'one',
|
||||||
default => 'two',
|
default => 'two'
|
||||||
};
|
};
|
||||||
-----
|
-----
|
||||||
<?php
|
<?php
|
||||||
|
Loading…
x
Reference in New Issue
Block a user