Skip to content
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

The PR for version 1.5.3 breaks under PHP 7.x #54

Open
evmorris94 opened this issue Jul 30, 2024 · 3 comments
Open

The PR for version 1.5.3 breaks under PHP 7.x #54

evmorris94 opened this issue Jul 30, 2024 · 3 comments

Comments

@evmorris94
Copy link

evmorris94 commented Jul 30, 2024

Our team has a package that uses jenssegers/model. A week ago, Test tier deployments of OUR final release versions ran fine. Those deployments picked up jenssegers/model version 1.5.2 in composer.

Today, the identical application release code was deployed to our Stage tier servers and failed with the following message:
PHP Fatal error: Declaration of Jenssegers\Model\Model::offsetExists(Jenssegers\Model\mixed $offset): bool must be compatible with ArrayAccess::offsetExists($offset) in /home/cebs/apps/php/feed-analysis/releases/20240730081849/vendor/jenssegers/model/src/Model.php on line 866.
Version 1.5.3 of Jenssegers/model was picked by composer in this deployment.

Our servers are currently running PHP 7.4.33. We are upgrading (very soon) to PHP 8.3, but we are not quite there yet.

THIS PR has the breaking change: sasha-b-a@354187d.
Specifically the ArrayAccess PHP interface seems to be the culprit. In https://www.php.net/manual/en/class.arrayaccess.php the method signatures match what your PR implemented, and indicate that the interface has been around since PHP 5. However, I think the exact internal PHP signature for the return type changed (became more explicit) for the ArrayAccess methods between PHP 7 and 8. Your updated override signature in version 1.5.3 seems to NOT be backward compatible with PHP < 8.x.

I have tested the same logic on our PHP 8.3-enabled server and version 1.5.3 of this package seems to work fine there.

It seems to me that for version 1.5.3.1 or later of this package, you may need to update composer.json to only be valid for Laravel 9 and greater, since that's the first version of Laravel that MUST run on PHP 8.x or later. This should effectively resolve this issue, except for the already-released 1.5.3 tag.

@devwebapps
Copy link

We have the same problem. As a workaround, we run after deployment:
composer require jenssegers/model:1.5.2

A pretty dirty workaround, because we don't load the package directly in the composer.json, but instead load it from another package that is installed directly from the composer.json.

Of course it would be great if this problem could be fixed, otherwise we will have to add this package with the version information separately in the composer.json from now on.

@MathiasWeisheit
Copy link

I have the same problem.

Declaration of Jenssegers\Model\Model::offsetExists(Jenssegers\Model\mixed $offset): bool must be compatible with ArrayAccess::offsetExists($offset) {"exception":"[object] (Symfony\Component\ErrorHandler\Error\FatalError(code: 0): Declaration of Jenssegers\Model\Model::offsetExists(Jenssegers\Model\mixed $offset): bool must be compatible with ArrayAccess::offsetExists($offset) at /app/vendor/jenssegers/model/src/Model.php:11)
[stacktrace]

@mookman288
Copy link

I'm encountering this issue when using:

https://github.com/mikebronner/laravel-caffeine

Could this be resolved by setting the appropriate php version so composer drops down to 1.5.2 for <8.1?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants