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,
|
||||
// or if it's an array item with a comment above it.
|
||||
// Match always uses multiline formatting.
|
||||
if ($insertStr === ', ' &&
|
||||
($this->isMultiline($origNodes) || $arrItem->getComments())
|
||||
($this->isMultiline($origNodes) || $arrItem->getComments() ||
|
||||
$parentNodeClass === Expr\Match_::class)
|
||||
) {
|
||||
$insertStr = ',';
|
||||
$insertNewline = true;
|
||||
@ -1378,7 +1380,7 @@ abstract class PrettyPrinterAbstract {
|
||||
Stmt\Global_::class . '->vars' => ', ',
|
||||
Stmt\GroupUse::class . '->uses' => ', ',
|
||||
Stmt\Interface_::class . '->extends' => ', ',
|
||||
//Expr\Match_::class . '->arms' => ', ',
|
||||
Expr\Match_::class . '->arms' => ', ',
|
||||
Stmt\Property::class . '->props' => ', ',
|
||||
Stmt\StaticVar::class . '->vars' => ', ',
|
||||
Stmt\TraitUse::class . '->traits' => ', ',
|
||||
|
@ -1,7 +1,8 @@
|
||||
Matches
|
||||
-----
|
||||
<?php
|
||||
$value = match (1) {
|
||||
$value = match (1)
|
||||
{
|
||||
1
|
||||
=>
|
||||
'one'
|
||||
@ -10,11 +11,12 @@ $value = match (1) {
|
||||
$stmts[0]->expr->expr->arms[] = new Node\MatchArm(null, new Scalar\String_('two'));
|
||||
-----
|
||||
<?php
|
||||
$value = match (1) {
|
||||
$value = match (1)
|
||||
{
|
||||
1
|
||||
=>
|
||||
'one',
|
||||
default => 'two',
|
||||
default => 'two'
|
||||
};
|
||||
-----
|
||||
<?php
|
||||
|
Loading…
x
Reference in New Issue
Block a user