From 7fbdb79a082f2ea899d7edbb37ab659d8f391708 Mon Sep 17 00:00:00 2001 From: nikic Date: Mon, 3 Nov 2014 16:16:15 +0100 Subject: [PATCH] Fix whitespace when printing trait alias modifiers --- lib/PhpParser/PrettyPrinter/Standard.php | 2 +- .../NodeVisitor/NameResolverTest.php | 2 +- test/code/prettyPrinter/traitUse.test | 25 +++++++++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 test/code/prettyPrinter/traitUse.test diff --git a/lib/PhpParser/PrettyPrinter/Standard.php b/lib/PhpParser/PrettyPrinter/Standard.php index 791c57b..0c4e10f 100644 --- a/lib/PhpParser/PrettyPrinter/Standard.php +++ b/lib/PhpParser/PrettyPrinter/Standard.php @@ -541,7 +541,7 @@ class Standard extends PrettyPrinterAbstract public function pStmt_TraitUseAdaptation_Alias(Stmt\TraitUseAdaptation\Alias $node) { return (null !== $node->trait ? $this->p($node->trait) . '::' : '') . $node->method . ' as' - . (null !== $node->newModifier ? ' ' . $this->pModifiers($node->newModifier) : '') + . (null !== $node->newModifier ? ' ' . rtrim($this->pModifiers($node->newModifier), ' ') : '') . (null !== $node->newName ? ' ' . $node->newName : '') . ';'; } diff --git a/test/PhpParser/NodeVisitor/NameResolverTest.php b/test/PhpParser/NodeVisitor/NameResolverTest.php index 646fbf1..f0b3988 100644 --- a/test/PhpParser/NodeVisitor/NameResolverTest.php +++ b/test/PhpParser/NodeVisitor/NameResolverTest.php @@ -177,7 +177,7 @@ namespace NS; class A extends \NS\B implements \NS\C, \NS\D { use \NS\E, \NS\F, \NS\G { - f as private g; + f as private g; \NS\E::h as i; \NS\E::j insteadof \NS\F, \NS\G; } diff --git a/test/code/prettyPrinter/traitUse.test b/test/code/prettyPrinter/traitUse.test new file mode 100644 index 0000000..7455ea0 --- /dev/null +++ b/test/code/prettyPrinter/traitUse.test @@ -0,0 +1,25 @@ +Trait uses and adaptations +----- +