Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

inheritance of ArrayAccess: Uncaught ErrorException: Collection::offsetExists($key) [duplicate]

Tags:

php

laravel

php-8

Local server PHP Version 8.1.4, laravel project. Inside composer.json file I have:

"php": "^7.2.5", version  & "laravel/framework": "^7.0"

Error:

PHP Fatal error: During inheritance of ArrayAccess: Uncaught ErrorException: Return type of Illuminate\Support\Collection::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice

error displaying below like this :

like image 978
Alal Sardar Avatar asked Sep 12 '25 17:09

Alal Sardar


2 Answers

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/

like image 196
George Geoker Avatar answered Sep 15 '25 08:09

George Geoker


in your composer.json update line

"php": "^7.3",

to

"php": "^7.3|^8.1",

and run composer update

like image 21
nasim jahednia Avatar answered Sep 15 '25 06:09

nasim jahednia