grumphp icon indicating copy to clipboard operation
grumphp copied to clipboard

PHP 8.1 compatibility

Open veewee opened this issue 5 years ago • 23 comments

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

veewee avatar Nov 26 '21 09:11 veewee

Hi, thank you for this. Is it possible to update "psr/container" too?

simo-markus-noerenberg avatar Dec 15 '21 09:12 simo-markus-noerenberg

@veewee please also add psr/container there are packages that can't be upgrade because grumphp is still using v1

dvdknaap avatar Dec 16 '21 14:12 dvdknaap

Idd surely accept a PR for that.. care to give it a try?

veewee avatar Dec 16 '21 15:12 veewee

Idd surely accept a PR for that.. care to give it a try?

Please check #968

dvdknaap avatar Dec 16 '21 20:12 dvdknaap

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.

ctrl-f5 avatar Jan 19 '22 14:01 ctrl-f5

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 avatar Jan 19 '22 14:01 veewee

@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 avatar Jan 26 '22 23:01 tm1000

@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.

veewee avatar Jan 27 '22 07:01 veewee

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

leonexcc avatar Feb 04 '22 14:02 leonexcc

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.

veewee avatar Feb 04 '22 14:02 veewee

Also broken on PHP 8.0. Pinning amphp/parallel-functions to v1.0.0 fixes it for now.

AegirLeet avatar Feb 04 '22 14:02 AegirLeet

Also broken on php7.4 since parallel function 1.1.0, pinning does fix it there too

janvernieuwe avatar Feb 04 '22 14:02 janvernieuwe

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

veewee avatar Feb 04 '22 15:02 veewee

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 avatar Feb 05 '22 13:02 mougrim

@mougrim : I also patched this locked version to v1.5.1

veewee avatar Feb 07 '22 13:02 veewee

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

veewee avatar Feb 07 '22 17:02 veewee

Released the fixes for the serializable closure https://github.com/phpro/grumphp/releases/tag/v1.8.0

veewee avatar Feb 08 '22 07:02 veewee

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 avatar Mar 10 '22 21:03 danepowell

@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?

veewee avatar Mar 11 '22 07:03 veewee

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.

danepowell avatar Mar 11 '22 17:03 danepowell