对于那些偶然发现关于 ReflectionType::__toString() 已弃用的通知的人,请改用 ReflectionType::getName() 方法,该方法尚未记录。
(PHP 7, PHP 8)
ReflectionType 类报告有关函数的参数/返回类型或类的属性类型的信息。Reflection 扩展声明了以下子类型
版本 | 描述 |
---|---|
8.0.0 | ReflectionType 已变为抽象类,ReflectionType::isBuiltin() 已移至 ReflectionNamedType::isBuiltin()。 |
对于那些偶然发现关于 ReflectionType::__toString() 已弃用的通知的人,请改用 ReflectionType::getName() 方法,该方法尚未记录。
ReflectionType::getName() 方法不存在。这在过去可能是虚拟存在的,但现在不再如此。它存在于 ReflectionNamedType 中,ReflectionNamedType 曾经是 ReflectionType 的唯一子类。因此,您可以依赖于此。
但在 PHP 8 中,还有 ReflectionUnionType 不具有 getName() 方法。因此,为了支持 PHP 8,您需要同时支持 ReflectionNamedType 和 ReflectionUnionType。