Skip to content
Advertisement

HEROKU error: During inheritance of ArrayAccess

This is the log of heroku, previous version of my code was running perfect but I change some code and have this error. Rollback is no t solution same error now…

-----> Building on the Heroku-20 stack
-----> Using buildpack: heroku/php
-----> PHP app detected
-----> Bootstrapping...
-----> Installing platform packages...
       - php (8.1.0)
       - ext-mbstring (bundled with php)
       - composer (2.1.14)
       - apache (2.4.51)
       - nginx (1.20.2)
-----> Installing dependencies...

 PHP Fatal error:  During inheritance of ArrayAccess: Uncaught ErrorException: Return type of IlluminateSupportCollection::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /tmp/build_3007ab05/vendor/laravel/framework/src/Illuminate/Support/Collection.php:1349

Advertisement

Answer

I got the exact same error recently. My local php version is 8.0.13 and it is working fine, but when I uploaded it to heroku (the php version used here is 8.1) I got the error.

To solve the problem, I specified my php version in the composer.json to the exact same local php version that I’m using like this:

{
  "require": {
    "php": "8.0.13"
  }
}

Don’t forget to update the composer.lock, then upload it to heroku. Heroku will use that exact version.

I know it is not recommended to specify the exact version per https://devcenter.heroku.com/articles/php-support, but it is working fine as a workaround.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement