Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to rename classes and it's namespace #1382

Merged
merged 1 commit into from
May 9, 2019

Conversation

JanMikes
Copy link
Contributor

@JanMikes JanMikes commented May 3, 2019

Closes #1373

@JanMikes JanMikes force-pushed the class-renaming-support branch 2 times, most recently from 4be7840 to c78fbc3 Compare May 6, 2019 23:29
@JanMikes JanMikes marked this pull request as ready for review May 6, 2019 23:29
@JanMikes
Copy link
Contributor Author

JanMikes commented May 6, 2019

@TomasVotruba i have covered all scenarios i could think about with tests, they are working, rebased on master and squashed.

Though tests could cover refactoring with annotations and editing annotations return values/type hints. Feel free to update ;-)

I will be very happy for review.

@JanMikes JanMikes changed the title Failing tests for renaming class and changing namespace Add support to rename classes and it's namespace May 7, 2019
@TomasVotruba TomasVotruba self-requested a review May 7, 2019 12:04
Copy link
Member

@TomasVotruba TomasVotruba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added review, great work 👍

@TomasVotruba TomasVotruba self-requested a review May 7, 2019 12:13
@JanMikes JanMikes force-pushed the class-renaming-support branch from a3e8912 to 0e70233 Compare May 8, 2019 09:58
@JanMikes
Copy link
Contributor Author

JanMikes commented May 8, 2019

Ready for re-review :-).

Though i had tests failing locally, if i checked out master, same tests were failing as well, so i think these are not caused by this PR:

PHPUnit 8.1.3 by Sebastian Bergmann and contributors.

Runtime:       PHP 7.3.4 with Xdebug 2.7.0
Configuration: /Users/janmikes/Sites/rector/phpunit.xml

...............................................................  63 / 377 ( 16%)
..........................F.................................... 126 / 377 ( 33%)
............................................................... 189 / 377 ( 50%)
............................................................... 252 / 377 ( 66%)
........FF..................................................... 315 / 377 ( 83%)
..............................................................  377 / 377 (100%)

Time: 36.81 seconds, Memory: 238.50 MB

There were 3 failures:

1) Rector\DeadCode\Tests\Rector\MethodCall\RemoveDefaultArgumentValueRector\RemoveDefaultArgumentValueRectorTest::test
Caused by /Users/janmikes/Sites/rector/packages/DeadCode/tests/Rector/MethodCall/RemoveDefaultArgumentValueRector/Fixture/user_vendor_function.php.inc
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
 {\n
     public function run()\n
     {\n
-        userDefinedFunction();\n
+        userDefinedFunction([]);\n
     }\n
 }\n
 \n
 ?>\n
 '

/Users/janmikes/Sites/rector/src/Testing/PHPUnit/AbstractRectorTestCase.php:151
/Users/janmikes/Sites/rector/src/Testing/PHPUnit/AbstractRectorTestCase.php:126
/Users/janmikes/Sites/rector/packages/DeadCode/tests/Rector/MethodCall/RemoveDefaultArgumentValueRector/RemoveDefaultArgumentValueRectorTest.php:13

2) Rector\RemovingStatic\Tests\Rector\Class_\PassFactoryToEntityRector\PassFactoryToEntityRectorTest::test
Failed asserting that file "/tmp/rector_temp_tests/AnotherClassFactory.php" exists.

/Users/janmikes/Sites/rector/packages/RemovingStatic/tests/Rector/Class_/PassFactoryToEntityRector/PassFactoryToEntityRectorTest.php:20

3) Rector\RemovingStatic\Tests\Rector\Class_\PassFactoryToEntityRector\PassFactoryToEntityRectorTest::testMultipleArguments
Failed asserting that file "/tmp/rector_temp_tests/AnotherClassWithMoreArgumentsFactory.php" exists.

/Users/janmikes/Sites/rector/packages/RemovingStatic/tests/Rector/Class_/PassFactoryToEntityRector/PassFactoryToEntityRectorTest.php:32

FAILURES!
Tests: 377, Assertions: 1751, Failures: 3.

@TomasVotruba
Copy link
Member

Tests should pass, Travis is green on master
Try composer update locally, there are new dependencies

@JanMikes
Copy link
Contributor Author

JanMikes commented May 8, 2019

Try composer update locally, there are new dependencies

Thx for tip, this fixed 1 error, still 2 are there:

There were 2 failures:

1) Rector\RemovingStatic\Tests\Rector\Class_\PassFactoryToEntityRector\PassFactoryToEntityRectorTest::test
Failed asserting that file "/tmp/rector_temp_tests/AnotherClassFactory.php" exists.

/Users/janmikes/Sites/rector/packages/RemovingStatic/tests/Rector/Class_/PassFactoryToEntityRector/PassFactoryToEntityRectorTest.php:20

2) Rector\RemovingStatic\Tests\Rector\Class_\PassFactoryToEntityRector\PassFactoryToEntityRectorTest::testMultipleArguments
Failed asserting that file "/tmp/rector_temp_tests/AnotherClassWithMoreArgumentsFactory.php" exists.

/Users/janmikes/Sites/rector/packages/RemovingStatic/tests/Rector/Class_/PassFactoryToEntityRector/PassFactoryToEntityRectorTest.php:32

But since travis passes even here, i will ignore it, might be something with my local environment.

@JanMikes JanMikes force-pushed the class-renaming-support branch from 15d1f2d to f27d50e Compare May 8, 2019 10:44
@TomasVotruba
Copy link
Member

But since travis passes even here, i will ignore it, might be something with my local environment.

I'm suspecting Mac slashes in DIRECTORY_SEPARATOR. But let's skip it for now.

@TomasVotruba
Copy link
Member

I've added one commit. You'll have to pull it before squasing.

Just squash it and I'll merge it 👍

@JanMikes JanMikes force-pushed the class-renaming-support branch from 565d056 to 9958a44 Compare May 8, 2019 11:00
@TomasVotruba TomasVotruba merged commit 69c7a0e into master May 9, 2019
@TomasVotruba TomasVotruba deleted the class-renaming-support branch May 9, 2019 10:31
@TomasVotruba
Copy link
Member

Great job, thanks!

TomasVotruba added a commit that referenced this pull request Dec 4, 2021
rectorphp/rector-src@26166bd [Rectify] [Php81] Enable Rectify for New in Initialization only (#1382)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[RenameClassRector] Add support for renaming namespace of the class
2 participants