PHP 8.4.2 Released!

ReflectionType 类

(PHP 7, PHP 8)

简介

ReflectionType 类报告有关函数的参数/返回类型以及类的属性类型的信息。Reflection 扩展声明了以下子类型:

类摘要

abstract class ReflectionType implements Stringable {
/* 方法 */
public allowsNull(): bool
public __toString(): string
}

更新日志

版本 说明
8.0.0 ReflectionType 已成为抽象类,ReflectionType::isBuiltin() 已移至 ReflectionNamedType::isBuiltin()

目录

添加备注

用户贡献的备注 2 notes

up
42
1franck
4 years ago
For those who stumble on notice about ReflectionType::__toString() beeing deprecated, use method ReflectionNamedType::getName() instead which is not yet documented.
up
15
Ondej Mirtes
4 years ago
Method ReflectionType::getName() does not exist. This may have been virtually true in the past but not anymore. It exists on ReflectionNamedType which used to be the only child class of ReflectionType. So you could have kind of relied on that.

But in PHP 8 there's also ReflectionUnionType which doesn't have the getName() method. So in order to support PHP 8, you need to support both ReflectionNamedType and ReflectionUnionType.
To Top