PHP 8 support#3015
Conversation
|
@edudobay thank you for this PR
I think that we could just make that method
I don't think there's any way around this one in this particular case. We would have to overload the
This particular issue bothers me a bit because we're going to have to do this work all over again when all the other libraries have official releases to support PHP 8. I would rather just do all the work at once than do it twice. We can just leave this PR open for now until the other libraries release official support for PHP 8. |
|
@l0gicgate Sure, I'll make it Regarding dependencies, I'll just watch them for releases and ping a comment when they're all ready. |
|
Hi! I've updated the source branch and fixed some PHPStan issues that surfaced recently. I'm not sure if my solution was the way to go — the type hints that could go wrong are the ones for |
|
Hi @l0gicgate. All set for external projects! When slimphp/Slim-Psr7#169 is merged and release tags are ready for it and for I guess we will need to wait a few days for an official PHP 8.0 tag to be available in Travis CI, so we can fix that too, right? I'm not sure if we should otherwise remove "allowed to fail" from the nightly build. |
Once they release the official PHP 8.0 tag we can add it to the CI builds and leave the nightly build as "allowed to fail" as we will need it to examine the behavior of future versions on CI e.g: PHP 9 (long time from now) I will try and release the other repos this weekend! |
|
@l0gicgate Great, let me know if I can help with anything! |
|
@edudobay see the releases below: Slim-Psr7 1.3.0 Release We should be good to go for this PR after! |
|
@l0gicgate I've updated composer.json to require these latest |
| $callable = $callable->bindTo($this->container); | ||
| /** @var Closure $callable */ |
There was a problem hiding this comment.
can we put the comment above the variable?
There was a problem hiding this comment.
sure! Sorry I missed these little things :)
|
|
||
| protected static function disableXmlEntityLoader(bool $disable): bool | ||
| { | ||
| if (\LIBXML_VERSION >= 20900) { |
There was a problem hiding this comment.
Let's add this to the imports. We don't do \ in the codebase
use LIBXML_VERSION;| $middleware = $middleware->bindTo($this->container); | ||
| /** @var Closure $middleware */ |
There was a problem hiding this comment.
Let's put the comment above the variable
l0gicgate
left a comment
There was a problem hiding this comment.
Just a few little things then I'll merge
Changes:
* Make the call to libxml_disable_entity_loader conditional. This
function has been deprecated in PHP 8.0 and the new default is
equivalent to calling that function with `true`.
https://php.watch/versions/8.0/libxml_disable_entity_loader-deprecation
* Add PHPUnit 9.3 dependency — that's the first 9.x release to support
PHP 8. PHPUnit 8.x will not be upgraded to support PHP 8.
TODO:
* Some dependencies do not yet declare compatibility with PHP 8; this
package can currently only be installed on PHP 8 using the Composer
`--ignore-platform-reqs` flag. Apart from Slim dependencies, these are
the packages which do not yet support a "php:^8.0" requirement:
fig/http-message-util
laminas/laminas-diactoros
nyholm/psr7-server
The external package weirdan/prophecy-shim is required to support PHPUnit 8 and 9 simultaneously — we can't fully upgrade to PHPUnit 9 because it drops support for PHP 7.2, whereas PHPUnit 8 won't support PHP 8.
|
@l0gicgate I've fixed the issues you mentioned! |
PHP 8 support
This PR allows Slim to be installed in PHP 8 and passes all the tests and checks.
History: I've raised some points in #2977 (comment) and since that time I've worked around other repositories to make this possible. This is also my first open-source contribution to a major project :)
Test fixes:
MiddlewareDispatcher->addDeferred. PHPUnit 8 was miscalculating coverage – see https://coveralls.io/builds/33553304/source?filename=Slim/MiddlewareDispatcher.php.My questions:
disableXmlEntityLoaderas aprivate static method. Is this okay? I thought about making itprotectedor extracting it to a class, but I'm unsure about creating new "contracts".libxml_disable_entity_loader. Is it okay to just@codeCoverageIgnoresome part that will only run in PHP 7 or PHP 8? How should situations like this be handled?Dependencies: I have gone through all dependencies that are blocking the PHP 8 upgrade and temporarily linked to development branches where the PHP 8 issues are solved. Surely this must be addressed before this can be merged (this is isolated in a single commit that can be removed). Those are the open PRs, some by me and some by others: