PHP Conference Japan 2024

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()

目录

添加注释

用户贡献的注释 4 条注释

1franck
4 年前
对于那些偶然发现关于 ReflectionType::__toString() 已弃用的通知的人,请改用 ReflectionType::getName() 方法,该方法尚未记录。
Ondej Mirtes
4 年前
ReflectionType::getName() 方法不存在。这在过去可能是虚拟存在的,但现在不再如此。它存在于 ReflectionNamedType 中,ReflectionNamedType 曾经是 ReflectionType 的唯一子类。因此,您可以依赖于此。

但在 PHP 8 中,还有 ReflectionUnionType 不具有 getName() 方法。因此,为了支持 PHP 8,您需要同时支持 ReflectionNamedType 和 ReflectionUnionType。
benjamin dot morel at gmail dot com
4 年前
已知子类

- ReflectionNamedType
- ReflectionUnionType
roland at mxchange dot org
4 年前
我想是 <?php ReflectionNamedType::getName(); ?> ?
To Top