From cc8a5aec008951bb6c933c21490e76b6cac7e48e Mon Sep 17 00:00:00 2001 From: TomasVotruba Date: Mon, 16 Oct 2017 19:58:22 +0200 Subject: [PATCH] make it work again --- .../PseudoNamespaceToNamespaceRector.php | 12 ++++++++---- .../PseudoNamespaceToNamespaceRector/Test.php | 18 +++++++++--------- .../correct/correct3.php.inc | 2 +- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/Rector/Dynamic/PseudoNamespaceToNamespaceRector.php b/src/Rector/Dynamic/PseudoNamespaceToNamespaceRector.php index 83f8de999d5..fe558caf239 100644 --- a/src/Rector/Dynamic/PseudoNamespaceToNamespaceRector.php +++ b/src/Rector/Dynamic/PseudoNamespaceToNamespaceRector.php @@ -89,6 +89,10 @@ final class PseudoNamespaceToNamespaceRector extends AbstractRector $nameOrIdentifierNode->setAttribute('origNode', null); $newNameParts = [$this->oldToNewUseStatements[$oldName]]; } + + $nameOrIdentifierNode->parts = $newNameParts; + + return $nameOrIdentifierNode; } if ($nameOrIdentifierNode instanceof Identifier && $parentNode instanceof Class_) { @@ -97,12 +101,12 @@ final class PseudoNamespaceToNamespaceRector extends AbstractRector $this->newNamespace = implode('\\', $namespaceParts); - $newNameParts = [$lastNewNamePart]; + $nameOrIdentifierNode->name = $lastNewNamePart; + + return $nameOrIdentifierNode; } - $nameOrIdentifierNode->parts = $newNameParts; - - return $nameOrIdentifierNode; + return null; } /** diff --git a/tests/Rector/Dynamic/PseudoNamespaceToNamespaceRector/Test.php b/tests/Rector/Dynamic/PseudoNamespaceToNamespaceRector/Test.php index 099d6119f6f..fb4838e1433 100644 --- a/tests/Rector/Dynamic/PseudoNamespaceToNamespaceRector/Test.php +++ b/tests/Rector/Dynamic/PseudoNamespaceToNamespaceRector/Test.php @@ -9,15 +9,15 @@ final class Test extends AbstractConfigurableRectorTestCase { public function test(): void { -// $this->doTestFileMatchesExpectedContent( -// __DIR__ . '/wrong/wrong.php.inc', -// __DIR__ . '/correct/correct.php.inc' -// ); -// -// $this->doTestFileMatchesExpectedContent( -// __DIR__ . '/wrong/wrong2.php.inc', -// __DIR__ . '/correct/correct2.php.inc' -// ); + $this->doTestFileMatchesExpectedContent( + __DIR__ . '/wrong/wrong.php.inc', + __DIR__ . '/correct/correct.php.inc' + ); + + $this->doTestFileMatchesExpectedContent( + __DIR__ . '/wrong/wrong2.php.inc', + __DIR__ . '/correct/correct2.php.inc' + ); $this->doTestFileMatchesExpectedContent( __DIR__ . '/wrong/wrong3.php.inc', diff --git a/tests/Rector/Dynamic/PseudoNamespaceToNamespaceRector/correct/correct3.php.inc b/tests/Rector/Dynamic/PseudoNamespaceToNamespaceRector/correct/correct3.php.inc index 542ecb2f98c..d777ebce40d 100644 --- a/tests/Rector/Dynamic/PseudoNamespaceToNamespaceRector/correct/correct3.php.inc +++ b/tests/Rector/Dynamic/PseudoNamespaceToNamespaceRector/correct/correct3.php.inc @@ -2,7 +2,7 @@ declare(strict_types=1); namespace PHPUnit; -class TestCase +class TestCase { } \ No newline at end of file