NB: Local server PHP Version 8.1.4, laravel project inside composer.json file have "php": "^7.2.5", version & "laravel/framework": "^7.0"
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
5
Answers
You would need to upgrade your Laravel Framework version to at least version 8 and it’s dependencies using composer.
Reference: https://laravel.com/docs/8.x/releases
Or if you want to postpone it, you would need to add
#[ReturnTypeWillChange]
before declaring every function that throws the error. This is highly not advisable.P.S. If you updated your PHP version you would have to change the PHP version in composer to the one used, in your case it should be
"php": "^8.1.4"
That’s a php version issue. Upgrade laravel or downgrade PHP. This article covers how to downgrade the PHP version so it matches the Laravel Version.
https://bytexd.com/fix-laravel-return-type-of-illuminatesupportcollectionoffsetexistskey/
run "composer update" on your project directory and it will work .
in your composer.json update line
to
and run composer update
In my case, using a mac, turns out my php version was 8.1 which somehow is not compatible with laravel version 7. Tho most of these answers are correct, but they did not fix my issues. I followed these steps (if brew is installed):
Reference How can I easily switch between PHP versions on Mac OSX?