tp官方于2021年01月11日更新了6.0.6版本,已经支持了php8.0
composer update topthink/framework
PHP 8在PHP类型系统中进行了一些改进,例如,引入了Union Types,mixedtype等。
经过这些更改,Reflection API的某些方法会产生错误的结果。
在PHP8中,废弃了ReflectionParameter类中的三个方法
ReflectionParameter::getClass()
ReflectionParameter::isArray()
ReflectionParameter::isCallable()
thinkphp6框架的容器默认使用了ReflectionParameter::getClass(),在PHP8环境中直接报错中断。
Deprecated: Method ReflectionParameter::getClass() is deprecated in D:\WWW\tp6\vendor\topthink\framework\src\think\Container.php on line 443
ReflectionParameter::getClass()返回参数类的名称。但是,当使用联合类型时,null如果差异类类型在单个联合中,则它将返回。
ReflectionParameter::getType()取代getClass()方法。
请注意,getClass()方法会传回实作的ReflectionClass()物件__toString()。
如果只对名称感兴趣,则可以使用$param->getType()->getName()来返回名称
ReflectionParamete