During inheritance of JsonSerializable: Uncaught think\exception\ErrorException: Return type of think\Model::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /opt/www/data/thinkphp/library/think/Model.php:1438
Stack trace:
#0 /opt/www/data/thinkphp/library/think/Model.php(40): think\Error::appError(8192, 'Return type of ...', '/opt/www/data/t...', 1438)
#1 /opt/www/data/thinkphp/library/think/Loader.php(544): include('/opt/www/data/t...')
#2 /opt/www/data/thinkphp/library/think/Loader.php(58): think\__include_file('/opt/www/data/t...')
#3 /opt/www/data/application/admin/model/Admin.php(7): think\Loader::autoload('think\\Model')
#4 /opt/www/data/thinkphp/library/think/Loader.php(544): include('/opt/www/data/a...')
#5 /opt/www/data/thinkphp/library/think/Loader.php(58): think\__include_file('/opt/www/data/p...')
#6 /opt/www/data/application/admin/controller/Admin.php(319): think\Loader::autoload('app\\admin\\model...')
#7 [internal function]: app\admin\controller\Admin->getAllTowns()
#8 /opt/www/data/thinkphp/library/think/App.php(226): ReflectionMethod->invokeArgs(Object(app\admin\controller\Admin), Array)
#9 /opt/www/data/thinkphp/library/think/App.php(364): think\App::invokeMethod(Array)
#10 /opt/www/data/thinkphp/library/think/App.php(134): think\App::module(Array, Array, true)
#11 /opt/www/data/thinkphp/start.php(18): think\App::run()
#12 /opt/www/data/public/index.php(18): require('/opt/www/data/t...')
#13 {main}
解决办法: