-
-
Notifications
You must be signed in to change notification settings - Fork 327
Switch closure serializer for PHP 8.1 support #808
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
Conversation
src/Compiler/Compiler.php
Outdated
$wrapper = new SerializableClosure($closure); | ||
$reflector = $wrapper->getReflector(); | ||
$reflector = new ReflectionClosure($closure); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, it looks like #793 identified that laravel/serializable-closure
only supports PHP >= 7.4, and this package supports PHP >= 7.2, so we would need to have both the Laravel package and opis/closure
installed. 😢
Maybe it is time for PHP-DI to require supported PHP versions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The alternative I guess is for the project to maintain a compatible fork of opis/closure
. It'd be good to have some guidance of what the project maintainers envisage as a solution, so we can find a way forward.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't feel like that's necessary, given that Laravel has already relived this.
@mnapoli what is the likelihood that there can be a new major version of PHP-DI?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even if we don't get a major version bump for PHP-DI that only supports PHP 7.4+, I think that #793 is a fine interim solution to this problem. Yes, both closure packages would be installed, but in my opinion that's much more palatable than than getting spammed with deprecation messages. As it stands, PHP-DI is so noisy that I have to @
suppress it, which makes it a liability in my codebase.
Hopefully we can get some movement on this issue from the maintainer, and thanks to those who have offered solutions! Appreciate you all!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even if we bump the minimum requirement of PHP-DI to 7.3, we still need to use opis/closure
for PHP 7.3. This is because laravel/serializable-closure
really does require PHP 7.4, but allows it to be installed (but not used) in PHP 7.3 (see laravel/serializable-closure#31). Therefore, I think we really do need the solution provided by #793 / #810, but without PHP 7.2.
(And here is the requirement specifically in the code: https://github.com/laravel/serializable-closure/blob/bfbc6c8e85240d08d8324be3eae13b7563224a91/src/SerializableClosure.php#L28-L30)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh good point! Sorry, following this issue across months with 5 minute attention span is hard 😅 thanks for the reminder.
OK, so we need a combination of #793 + this PR + drop PHP 7.2 (and keep 7.3). @shadowhand are you able to do this in this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mnapoli on it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mnapoli there's another issue though, ocramius/proxy-manager
can't be installed on PHP 8.1 because it version locks PHP as ~8.0.0
as of the latest version 2.14.1
and there is no (released) version that supports PHP 8.1. I can work around it, but I am mentioning it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ocramius/proxy-manager can't be installed on PHP 8.1 because it version locks PHP as ~8.0.0 as of the latest version 2.14.1 and there is no (released) version that supports PHP 8.1.
Right yes, that's why I think it's OK if we don't run CI on 8.1 (unless you have a better idea in mind)
I still don't love this. I hope that PHP-DI 7.0 can land soon. |
@mnapoli test errors should be fixed now. |
@@ -42,7 +42,7 @@ public function resolve(Definition $definition, array $parameters = []) : array | |||
$values = $definition->getValues(); | |||
|
|||
// Resolve nested definitions | |||
array_walk_recursive($values, function (&$value, $key) use ($definition) { | |||
array_walk_recursive($values, function (& $value, $key) use ($definition) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
composer format-code
changed this.
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "^8.5|^9.0", | ||
"mnapoli/phpunit-easymock": "^1.2", | ||
"doctrine/annotations": "~1.2", | ||
"ocramius/proxy-manager": "^2.0.2", | ||
"ocramius/proxy-manager": "^2.2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed this to fix this test error, per zendframework/zend-stdlib#97.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ocramius/proxy-manager 2.2.0 requires zendframework/zend-code (^3.3.0)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know what to do about this test error, because all versions of zendframework/zend-eventmanager allow for version ^2.7 || ^3.0
of zend-stdlib
, and newer versions of proxy-manager require php ^7.4
. There is simply no way to resolve the build error while using --prefer-lowest
.
@mnapoli updated to fix newest build error. |
Since we're stuck with PHP 7.3 support and this has been the case for a while, let's jump the gun and support PHP 7.4+ ? I've implemented that in #811 based on this PR. |
Thanks! |
@mnapoli @shadowhand This Pull Request changed change-log.md, which was unmaintained for quite a while. Thus the version number mentioned there for this change (6.1.0) does not match reality (6.4.0). I’d suggest either removing this file completely, if maintaining in the future is not planned, or fixing this issue and filling the gap for the versions in between. |
Good point, PR welcome (I'm at a conference + launching a new major thing this week) |
@mnapoli PR in which direction: Removing the change log or bringing it back up to date? |
I don't have a vote, but my vote is to bring the changelog up to date. Services like Dependabot use it. |
Ideally updating it as it's currently used in the website: https://php-di.org/change-log.html |
Fixes #791