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

PHP Parse error @PHPUnit60Migration #4417

Closed
ktomk opened this issue May 21, 2019 · 1 comment
Closed

PHP Parse error @PHPUnit60Migration #4417

ktomk opened this issue May 21, 2019 · 1 comment
Labels

Comments

@ktomk
Copy link
Contributor

ktomk commented May 21, 2019

When using the @PHPUnit60Migration:riky ruleset (effectively the PhpUnitNamespacedFixer) PHP-CS-Fixer was not able to fix files due to resulting the fixes into a PHP Parse error:

PHP Parse error: syntax error, unexpected 'Return' (T_RETURN), expecting identifier (T_STRING)

This is when changing the class PHPUnit_Framework_MockObject_Stub_Return into the new namespaced class PHPUnit\Framework\MockObject\Stub\Return.

Changing the class-name string PHPUnit_Framework_MockObject_Stub_Return to PHPUnit_Framework_MockObject_Stub_ReturnStub results in the correct new type PHPUnit\Framework\MockObject\Stub\ReturnStub.


The PHP version you are using ($ php -v):

PHP 7.1.29-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: May 3 2019 09:51:29) ( NTS )

PHP CS Fixer version you are using ($ php-cs-fixer -V):

master / PHP CS Fixer 2.16.0-DEV by Fabien Potencier and Dariusz Ruminski

The command you use to run PHP CS Fixer:

php7.1 -n -dextension=tokenizer.so -dextension=json.so -dextension=ctype.so -dextension=iconv.so \
  -f../PHP-CS-Fixer/php-cs-fixer -- fix -vvv \
  --rules=@PHPUnit60Migration:risky,-php_unit_mock \
  tests
ktomk added a commit to ktomk/PHP-CS-Fixer that referenced this issue May 21, 2019
When cs-fix the name-space of the class

    PHPUnit_Framework_MockObject_Stub_Return

it results in a new class name which causes a PHP parse error b/c of the
reserved word "return" as the new class-name.

Phpunit has renamed that class to ...\ReturnStub (5 -> 6).

Fix is to translate it to the "new" name so that it transposes correctly.

Issue: PHP-CS-Fixer#4417
Fixer: PhpUnitNamespacedFixer
ktomk added a commit to ktomk/PHP-CS-Fixer that referenced this issue May 21, 2019
When cs-fix the name-space of the class

    PHPUnit_Framework_MockObject_Stub_Return

it results in a new class name which causes a PHP parse error b/c of the
reserved word "return" as the new class-name.

Phpunit has renamed that class to ...\ReturnStub (5 -> 6).

Fix is to translate it to the "new" name so that it transposes correctly.

Issue: PHP-CS-Fixer#4417
Fixer: PhpUnitNamespacedFixer
ktomk added a commit to ktomk/PHP-CS-Fixer that referenced this issue May 21, 2019
When cs-fix the name-space of the class

    PHPUnit_Framework_MockObject_Stub_Return

it results in a new class name which causes a PHP parse error b/c of the
reserved word "return" as the new class-name.

Phpunit has renamed that class to ...\ReturnStub (5 -> 6).

Fix is to translate it to the "new" name so that it transposes correctly.

Similar but w/o parse error is PHPUnit_Framework_Error which now is
PHPUnit\Framework\Error\Error.

Issue: PHP-CS-Fixer#4417
Fixer: PhpUnitNamespacedFixer
ktomk added a commit to ktomk/PHP-CS-Fixer that referenced this issue May 22, 2019
When cs-fix the name-space of the class

    PHPUnit_Framework_MockObject_Stub_Return

it resulted in a new class name which causes a PHP parse error b/c of the
reserved word "return" as the new class-name.

Phpunit has renamed that class to ...\ReturnStub (5 -> 6).

Fix is to translate it to the "new" name so that it transposes correctly.

Similar but w/o parse error is PHPUnit_Framework_Error which now is
PHPUnit\Framework\Error\Error.

Comparing all Phpunit 5 classes against Phpunit 6 classes results in the
full translation table leaving nine classes unresolved:

* PHPUnit_Extensions_TicketListener
* PHPUnit_Extensions_PhptTestSuite
* PHPUnit_Extensions_TestDecorator
* PHPUnit_Extensions_RepeatedTest
* PHPUnit_Extensions_GroupTestSuite
* PHPUnit_Util_Log_JSON
* PHPUnit_Util_Log_TAP
* PHPUnit_Util_String
* PHPUnit_Util_PHPTest

Issue: PHP-CS-Fixer#4417
Fixer: PhpUnitNamespacedFixer
@ktomk
Copy link
Contributor Author

ktomk commented May 22, 2019

Checked against all Phpunit 5 and 6 class names to make the change more complete.

ktomk added a commit to ktomk/PHP-CS-Fixer that referenced this issue May 22, 2019
When cs-fix the name-space of the class

    PHPUnit_Framework_MockObject_Stub_Return

it resulted in a new class name which causes a PHP parse error b/c of the
reserved word "return" as the new class-name.

Phpunit has renamed that class to ...\ReturnStub (5 -> 6).

Fix is to translate it to the "new" name so that it transposes correctly.

Similar but w/o parse error is PHPUnit_Framework_Error which now is
PHPUnit\Framework\Error\Error.

Comparing all Phpunit 5 classes against Phpunit 6 classes results in the
full translation table leaving nine classes unresolved:

* PHPUnit_Extensions_TicketListener
* PHPUnit_Extensions_PhptTestSuite
* PHPUnit_Extensions_TestDecorator
* PHPUnit_Extensions_RepeatedTest
* PHPUnit_Extensions_GroupTestSuite
* PHPUnit_Util_Log_JSON
* PHPUnit_Util_Log_TAP
* PHPUnit_Util_String
* PHPUnit_Util_PHPTest

Issue: PHP-CS-Fixer#4417
Fixer: PhpUnitNamespacedFixer
ktomk added a commit to ktomk/PHP-CS-Fixer that referenced this issue May 22, 2019
When cs-fix the name-space of the class

    PHPUnit_Framework_MockObject_Stub_Return

it resulted in a new class name which causes a PHP parse error b/c of the
reserved word "return" as the new class-name.

Phpunit has renamed that class to ...\ReturnStub (5 -> 6).

Fix is to translate it to the "new" name so that it transposes correctly.

Similar but w/o parse error is PHPUnit_Framework_Error which now is
PHPUnit\Framework\Error\Error.

Comparing all Phpunit 5 classes against Phpunit 6 classes results in the
full translation table leaving nine classes unresolved:

* PHPUnit_Extensions_TicketListener
* PHPUnit_Extensions_PhptTestSuite
* PHPUnit_Extensions_TestDecorator
* PHPUnit_Extensions_RepeatedTest
* PHPUnit_Extensions_GroupTestSuite
* PHPUnit_Util_Log_JSON
* PHPUnit_Util_Log_TAP
* PHPUnit_Util_String
* PHPUnit_Util_PHPTest

Issue: PHP-CS-Fixer#4417
Fixer: PhpUnitNamespacedFixer
ktomk added a commit to ktomk/PHP-CS-Fixer that referenced this issue May 22, 2019
When cs-fix the name-space of the class

    PHPUnit_Framework_MockObject_Stub_Return

it resulted in a new class name which causes a PHP parse error b/c of the
reserved word "return" as the new class-name.

Phpunit has renamed that class to ...\ReturnStub (5 -> 6).

Fix is to translate it to the "new" name so that it transposes correctly.

Similar but w/o parse error is PHPUnit_Framework_Error which now is
PHPUnit\Framework\Error\Error.

Comparing all Phpunit 5 classes against Phpunit 6 classes results in the
full translation table leaving nine classes unresolved:

* PHPUnit_Extensions_TicketListener
* PHPUnit_Extensions_PhptTestSuite
* PHPUnit_Extensions_TestDecorator
* PHPUnit_Extensions_RepeatedTest
* PHPUnit_Extensions_GroupTestSuite
* PHPUnit_Util_Log_JSON
* PHPUnit_Util_Log_TAP
* PHPUnit_Util_String
* PHPUnit_Util_PHPTest

Issue: PHP-CS-Fixer#4417
Fixer: PhpUnitNamespacedFixer
ktomk added a commit to ktomk/PHP-CS-Fixer that referenced this issue May 22, 2019
When cs-fix the name-space of the class

    PHPUnit_Framework_MockObject_Stub_Return

it resulted in a new class name which causes a PHP parse error b/c of the
reserved word "return" as the new class-name.

Phpunit has renamed that class to ...\ReturnStub (5 -> 6).

Fix is to translate it to the "new" name so that it transposes correctly.

Similar but w/o parse error is PHPUnit_Framework_Error which now is
PHPUnit\Framework\Error\Error.

Comparing all Phpunit 5 classes against Phpunit 6 classes results in the
full translation table leaving nine classes unresolved:

* PHPUnit_Extensions_TicketListener
* PHPUnit_Extensions_PhptTestSuite
* PHPUnit_Extensions_TestDecorator
* PHPUnit_Extensions_RepeatedTest
* PHPUnit_Extensions_GroupTestSuite
* PHPUnit_Util_Log_JSON
* PHPUnit_Util_Log_TAP
* PHPUnit_Util_String
* PHPUnit_Util_PHPTest

Issue: PHP-CS-Fixer#4417
Fixer: PhpUnitNamespacedFixer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants