mezzio / mezzio-hal

Hypertext Application Language implementation for PHP and PSR-7

Home Page:https://docs.mezzio.dev/mezzio-hal/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PHP 8.0 support

boesing opened this issue · comments

Feature Request

Q A
New Feature yes

Summary

To be prepared for the december release of PHP 8.0, this repository has some additional TODOs to be tested against the new major version.

In order to make this repository compatible, one has to follow these steps:

  • Modify composer.json to provide support for PHP 8.0 by adding the constraint ~8.0.0
  • Modify composer.json to drop support for PHP less than 7.3
  • Modify composer.json to implement phpunit 9.3 which supports PHP 7.3+
  • Modify .travis.yml to ignore platform requirements when installing composer dependencies (simply add --ignore-platform-reqs to COMPOSER_ARGS env variable)
  • Modify .travis.yml to add PHP 8.0 to the matrix (NOTE: Do not allow failures as PHP 8.0 has a feature freeze since 2020-08-04!)
  • Modify source code in case there are incompatibilities with PHP 8.0

Hi @boesing

Do you need help with this? I'd be happy to pick it up

@agustingomes Feel free, the Help Wanted label is definitely to mark this issue open for contributors. 👍

Perfect, I will proceed with it.

Just a couple of questions:

  • should we add a helper in the project to cover the tests using assertAttributeInstanceOf? this method is not available in PHPUnit 9
  • should I address already the Prophecy removal? it's currently deprecated and it will be removed in PHPUnit 10

so in the effort of making the tests pass for PHP 8, i ran into the same problem as described here: mezzio/mezzio-problem-details#10

@froschdesign I ran the composer install only with php 7.3, so I'll need to check it in php8 to replicate that travis result. thanks for the heads up.

Locally, i ran into that match problem:

PHPUnit 9.4.4 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.0.0
Configuration: /opt/project/phpunit.xml.dist
Warning:       Your XML configuration validates against a deprecated schema.
Suggestion:    Migrate your XML configuration using "--migrate-configuration"!

.............................................................WW  63 / 243 ( 25%)
WEEEEEEEEEEWWWWWWWWW.WW........................................ 126 / 243 ( 51%)
.......................................WWWWWWWWWWWWWWWWWW...... 189 / 243 ( 77%)
.WW.......WWWWWW.......WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW          243 / 243 (100%)

Time: 00:15.730, Memory: 20.00 MB

There were 10 errors:

1) MezzioTest\Hal\HalResponseFactoryTest::testReturnsJsonResponseIfNoAcceptHeaderPresent
ParseError: syntax error, unexpected token "match"

/opt/project/vendor/willdurand/negotiation/src/Negotiation/Negotiator.php:41
/opt/project/src/HalResponseFactory.php:63
/opt/project/test/HalResponseFactoryTest.php:53

@boesing regarding adding --ignore-platform-reqs, is there a reason why we want to add that flag to the dependency installation? it feels counterintuitive to add it, but I may be missing some context around the reason for adding it.

@boesing regarding adding --ignore-platform-reqs, is there a reason why we want to add that flag to the dependency installation? it feels counterintuitive to add it, but I may be missing some context around the reason for adding it.

When the issue was created, there was no stable version of PHP 8.0 and thus most the packages on packagist did not properly support PHP 8.0.
If we can omit that flag, feel free to drop it.

Ah, I see.

Well, there are some packages that still fail to be installed because they don't have a version with explicit php 8 support yet, so for the time being, I think we can keep that flag.

Fixed with #21 and released with 1.4.0.