Skip to content

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

@evmorris94

Description

@evmorris94

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions