PHP Fatal error: During inheritance of ArrayAccess: Uncaught ErrorException: Return type of think\Container::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 /www/wwwroot/webman/vendor/topthink/think-container/src/Container.php:567
thinkphp-container 不兼容 php8.1 導(dǎo)致的
在 PHP 8.1 之前,任何擴(kuò)展ArrayAccess接口的類都不需要添加返回類型
從 PHP 8.1 及更高版本開始,缺少返回類型的聲明會導(dǎo)致棄用通知:
解決方法,打開 \vendor\topthink\think-container\src\Container.php
,搜索
offsetExists($key)
改為 offsetExists($key):bool
offsetSet($key, $value)
改為 offsetSet($key, $value):void
offsetGet($key)
改為 offsetGet($key):mixed
offsetUnset($key)
改為 offsetUnset($key):void
getIterator()
改為 getIterator():IteratorAggregate
count()
改為 count():int
兼容8.1 需要版本大于等于
v2.0.46
版本才會兼容,你這個topthink/think-orm v2.0.12 think orm
是v2.0.12
就是不兼容的。兼容8.1:https://github.com/top-think/think-orm/commit/c422dbaa80671f120c0fef2acfe28ecb7dd1b794