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

[CI] Add PHP 8.0 to Github actions tests #4779

Merged
merged 36 commits into from
Dec 5, 2020
Merged

[CI] Add PHP 8.0 to Github actions tests #4779

merged 36 commits into from
Dec 5, 2020

Conversation

samsonasik
Copy link
Member

No description provided.

@samsonasik
Copy link
Member Author

Got php 8 downgrade errors:

Downgrade Class On Object To Get Class Rector (Rector\DowngradePhp80\Tests\Rector\ClassConstFetch\DowngradeClassOnObjectToGetClassRector\DowngradeClassOnObjectToGetClassRector)
 ✘  with data set #0
   │
   │ rules/downgrade-php80/tests/Rector/ClassConstFetch/DowngradeClassOnObjectToGetClassRector/Fixture/fixture.php.inc
   │ Failed asserting that string matches format description.
   │ --- Expected
   │ +++ Actual
   │ @@ @@
   │  {
   │      public function run($object)
   │      {
   │ -        return get_class($object);
   │ +        return $object::class;
   │      }
   │  }
   │
   │ /home/runner/work/rector/rector/packages/testing/src/PHPUnit/AbstractRectorTestCase.php:486
   │ /home/runner/work/rector/rector/packages/testing/src/PHPUnit/AbstractRectorTestCase.php:308
   │ /home/runner/work/rector/rector/rules/downgrade-php80/tests/Rector/ClassConstFetch/DowngradeClassOnObjectToGetClassRector/DowngradeClassOnObjectToGetClassRectorTest.php:21
   │


Downgrade Return Static Type Declaration Rector (Rector\DowngradePhp80\Tests\Rector\FunctionLike\DowngradeReturnStaticTypeDeclarationRector\DowngradeReturnStaticTypeDeclarationRector)
 ✘  with data set #0
   │
   │ rules/downgrade-php80/tests/Rector/FunctionLike/DowngradeReturnStaticTypeDeclarationRector/Fixture/fixture.php.inc
   │ /home/runner/work/rector/rector/src/Application/FileProcessor.php:143
   │ /home/runner/work/rector/rector/packages/testing/src/PHPUnit/AbstractRectorTestCase.php:439
   │ /home/runner/work/rector/rector/packages/testing/src/PHPUnit/AbstractRectorTestCase.php:308
   │ /home/runner/work/rector/rector/rules/downgrade-php80/tests/Rector/FunctionLike/DowngradeUnionTypeReturnDeclarationRector/DowngradeUnionTypeReturnDeclarationRectorTest.php:23
   │

Downgrade Union Type Typed Property Rector (Rector\DowngradePhp80\Tests\Rector\Property\DowngradeUnionTypeTypedPropertyRector\DowngradeUnionTypeTypedPropertyRector)
 ✘  with data set #0
   │
   │ Rector\Core\Exception\NotImplementedException: PhpParser\Node\UnionType
   │
   │ /home/runner/work/rector/rector/packages/static-type-mapper/src/Mapper/PhpParserNodeMapper.php:45
   │ /home/runner/work/rector/rector/packages/static-type-mapper/src/StaticTypeMapper.php:82
   │ /home/runner/work/rector/rector/rules/downgrade-php74/src/Rector/Property/AbstractDowngradeTypedPropertyRector.php:45
   │ /home/runner/work/rector/rector/src/Rector/AbstractRector.php:231
   │ /home/runner/work/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:200
   │ /home/runner/work/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:114
   │ /home/runner/work/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:223
   │ /home/runner/work/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:114
   │ /home/runner/work/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:223
   │ /home/runner/work/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:91
   │ /home/runner/work/rector/rector/src/PhpParser/NodeTraverser/RectorNodeTraverser.php:119
   │ /home/runner/work/rector/rector/src/Application/FileProcessor.php:143
   │ /home/runner/work/rector/rector/packages/testing/src/PHPUnit/AbstractRectorTestCase.php:439
   │ /home/runner/work/rector/rector/packages/testing/src/PHPUnit/AbstractRectorTestCase.php:308
   │ /home/runner/work/rector/rector/rules/downgrade-php80/tests/Rector/Property/DowngradeUnionTypeTypedPropertyRector/DowngradeUnionTypeTypedPropertyRectorTest.php:2

@samsonasik
Copy link
Member Author

@TomasVotruba It seems isAtLeastPhpVersion() not works for php 8, debug with the following:

        dump(
            PHP_VERSION,
            $this->isAtLeastPhpVersion(PhpVersionFeature::CLASS_ON_OBJECT)
        );

got:

"8.0.0" (5)
false

@samsonasik
Copy link
Member Author

It seems because of test definition:

    protected function getPhpVersion(): int
    {
        return PhpVersionFeature::CLASS_ON_OBJECT - 1;
    }

@samsonasik
Copy link
Member Author

Got weird error at Rector\Naming\Tests\Rector\Assign\RenameVariableToMatchMethodCallReturnTypeRector\Php74Test

Php74 (Rector\Naming\Tests\Rector\Assign\RenameVariableToMatchMethodCallReturnTypeRector\Php74)
 ✘  with data set #0
   │
   │ rules/naming/tests/Rector/Assign/RenameVariableToMatchMethodCallReturnTypeRector/FixturePhp74/arrow_function.php.inc
   │ Failed asserting that string matches format description.
   │ --- Expected
   │ +++ Actual
   │ @@ @@
   │      {
   │          $datetime = new DateTime();
   │  
   │ -        $fn1 = fn($x) => $x + $dateTimeZone = $datetime->getTimezone();
   │ +        $fn1 = fn($x) => $x + $timezone = $datetime->getTimezone();
   │      }
   │  }

@samsonasik
Copy link
Member Author

More error in test in php 8 :

To String To Method Call Rector (Rector\MagicDisclosure\Tests\Rector\String_\ToStringToMethodCallRector\ToStringToMethodCallRector)
 ✔  with data set #0
PHP Fatal error:  Cannot use "parent" when current class scope has no parent in /tmp/_temp_fixture_easy_testing/input_d61e4d22d14036671bb8_rename_class_method_and_parent_call.php on line 19

seems need to be fixed in somewhere in the code instead

@@ -13,7 +13,7 @@
final class DowngradeReturnStaticTypeDeclarationRectorTest extends AbstractRectorTestCase
{
/**
* @requires PHP >= 8.0
* @requires PHP >= 9.0
Copy link
Member Author

Choose a reason for hiding this comment

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

@TomasVotruba I set temporary this as test is not working:

Downgrade Union Type Typed Property Rector (Rector\DowngradePhp80\Tests\Rector\Property\DowngradeUnionTypeTypedPropertyRector\DowngradeUnionTypeTypedPropertyRector)
 ✘  with data set #0
   │
   │ Rector\Core\Exception\NotImplementedException: PhpParser\Node\UnionType
   │
   │ /home/runner/work/rector/rector/packages/static-type-mapper/src/Mapper/PhpParserNodeMapper.php:45
   │ /home/runner/work/rector/rector/packages/static-type-mapper/src/StaticTypeMapper.php:82
   │ /home/runner/work/rector/rector/rules/downgrade-php74/src/Rector/Property/AbstractDowngradeTypedPropertyRector.php:45
   │ /home/runner/work/rector/rector/src/Rector/AbstractRector.php:231
   │ /home/runner/work/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:200
   │ /home/runner/work/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:114
   │ /home/runner/work/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:223
   │ /home/runner/work/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:114
   │ /home/runner/work/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:223
   │ /home/runner/work/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:91
   │ /home/runner/work/rector/rector/src/PhpParser/NodeTraverser/RectorNodeTraverser.php:119
   │ /home/runner/work/rector/rector/src/Application/FileProcessor.php:143
   │ /home/runner/work/rector/rector/packages/testing/src/PHPUnit/AbstractRectorTestCase.php:439
   │ /home/runner/work/rector/rector/packages/testing/src/PHPUnit/AbstractRectorTestCase.php:308
   │ /home/runner/work/rector/rector/rules/downgrade-php80/tests/Rector/Property/DowngradeUnionTypeTypedPropertyRector/DowngradeUnionTypeTypedPropertyRectorTest.php:23

Copy link
Member Author

Choose a reason for hiding this comment

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

marked to 8.1 seems works, this is temporary to be fixed in the future.

@samsonasik
Copy link
Member Author

All checks have passed 🎉 @TomasVotruba it is ready for review.

@TomasVotruba
Copy link
Member

@TomasVotruba It seems isAtLeastPhpVersion() not works for php 8, debug with the following:

        dump(
            PHP_VERSION,
            $this->isAtLeastPhpVersion(PhpVersionFeature::CLASS_ON_OBJECT)
        );

got:

"8.0.0" (5)
false

Instead of PHP_VERSION, it should be PHP_VERSION_ID

@TomasVotruba
Copy link
Member

Let's go :)

@TomasVotruba TomasVotruba merged commit 1e667b4 into master Dec 5, 2020
@TomasVotruba TomasVotruba deleted the php8 branch December 5, 2020 11:10
@TomasVotruba
Copy link
Member

Most of the skipped test cases are fixed here:
#4805

@samsonasik
Copy link
Member Author

Thank you

TomasVotruba added a commit that referenced this pull request Aug 13, 2023
rectorphp/rector-src@2970fa1 [TypeDeclaration] Skip in conditional on AddParamTypeFromPropertyTypeRector (#4779)
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.

2 participants