PHP 8.1 compatibility
| Q | A |
|---|---|
| Version | vendor/bin/grumphp -V |
| Bug? | no |
| New feature? | no |
| Question? | no |
| Documentation? | no |
| Related tickets |
We added PHP 8.1 compatibility in #956. However, not all downstream packages are fully compatible yet. Therefore, you might still see some deprecation warnings. The tool itself should be working though!
Awaiting deps:
- [x] opis/closure: https://github.com/opis/closure/pull/105
- [x] opis/closure: https://github.com/opis/closure/issues/59
- [x] laravel/closure if amphp/parallel-functions wants to use that: https://github.com/amphp/parallel-functions/pull/29
Awaiting dev deps
- [x] phpspec: https://github.com/phpspec/phpspec/pull/1397
Awaiting shim deps (patched locally)
- [x] humbug/box & scoper: https://github.com/box-project/box/issues/562
- [x] scoper issue with serializable closure: https://github.com/humbug/php-scoper/issues/642
- [x] scoper issue with union return types https://github.com/humbug/php-scoper/issues/643
- [x] New shim build setup : https://github.com/phpro/grumphp-shim/pull/17
Broken Tests
- [ ] ~Fix skipped E2E tests~ - currently won't do. They seem buggy edge cases anyways. If there is any need for them to still work, time can be invested
Hi, thank you for this. Is it possible to update "psr/container" too?
@veewee please also add psr/container there are packages that can't be upgrade because grumphp is still using v1
Idd surely accept a PR for that.. care to give it a try?
Idd surely accept a PR for that.. care to give it a try?
Please check #968
Are you guys willing to switch to the https://github.com/laravel/serializable-closure fork?
Since I agree with the remarks on opis/closure that depending on FFI is not a very good idea.
I am willing to switch to whatever works best.
What is the reason that depending on FFI is not a good idea? Is FFI enabled by default on CLI or opt-in?
However, amphp/parallel-functions is still using opis/closure, so I don't know if we can rule it out completely:
https://github.com/amphp/parallel-functions/blob/master/composer.json#L29
Lets keep an eye on this issue as well: https://github.com/amphp/parallel-functions/pull/29
@veewee there are some remarks in the opis/closure thread that FFI is also very slow
See: https://github.com/opis/closure/issues/102#issuecomment-919341805
Using laravel/serializable-closure would at least fix the deprecation notices right now and you can look into going to opis/closure in the future.
@tm1000 it's not that simple ... laravel/closure is not marked as a replacement for opis/closure. See composer.json So even if we switched to laravel/closure, it 'll still mean that amp/parallel-functions would have to use that same package internally. Since the namespace changed, it cannot be marked as a replacement anyways.
So I am waiting to see what AMP is going to do at this moment.
amphp/parallel-functions released a version 1.1.0 with laravel/closure. This now breaks grumphp on PHP 8.1 with:
Uncaught Amp\Serialization\SerializationException in worker with message "The given data could not be serialized: Laravel\SerializableClosure\Support\ReflectionClosure::__construct(): Argument #1 ($closure) must be of type Closure, Opis\Closure\SerializableClosure given, called in .../vendor/laravel/serializable-closure/src/Serializers/Native.php on line 300" and code "0"; use Amp\Parallel\Worker\TaskFailureException::getOriginalTrace() for the stack trace in the worker
Nice! Thanks for mentoning @leonexcc.
Someone interested in implementing the Laravel serializable closures in here? I'm a bit short on time ATM, so it might take a while from my side.
Also broken on PHP 8.0. Pinning amphp/parallel-functions to v1.0.0 fixes it for now.
Also broken on php7.4 since parallel function 1.1.0, pinning does fix it there too
Locked it to 1.0 for 1.7.1. We can launch the compatibility with the new larevel version in grumphp v1.8 - but that will fix composer update issues for now
Hi! Could somebody do same fix as https://github.com/phpro/grumphp/pull/981 and https://github.com/phpro/grumphp/pull/982 for grumphp v1.5.0?
Grumphp 1.7.1 requires php8.0, bug php7.4 is still supported (have security fixes).
Or say, how to do it correctly (I see here only master branch).
@mougrim : I also patched this locked version to v1.5.1
FYI : found a solution for using PHP 81 compatible laravel closures. Will release it soon. Feel free to test it out on master!
First trying to get box to work as well for grumphp-shim, since it now is PHP 81 compatible. More info: https://github.com/humbug/php-scoper/issues/642
Released the fixes for the serializable closure https://github.com/phpro/grumphp/releases/tag/v1.8.0
I'm still seeing this using v1.5.1 on PHP 7.4:
PHP Deprecated: GrumPHP\Collection\FilesCollection implements the Serializable interface, which is deprecated.
I presume this is fixed in v1.8.1, but can we get this backported to a version compatible with PHP 7.4 as well?
@danepowell I'm a bit confused here. That interface is deprecated in php 8.1. Since you are on 7.4, you shouldnt be getting that deprecation warning?
No problem, I should have explained. We use grumphp in a packaged application that must run on any supported PHP version (7.4-8.1). Thus we need to use grumphp v1.5.1, as it's the latest to support PHP 7.4. But if a user on PHP 8.1 runs our app, they get the deprecation errors.
Specifically, we use Composer's platform config to mandate support of PHP 7.4 in our composer.json.