ReflectionNamedType 类
(PHP 7 >= 7.1.0, PHP 8)
简介
类摘要
/* 方法 */
/* 继承的方法 */
}目录
- ReflectionNamedType::getName — 以字符串形式获取类型的名称
- ReflectionNamedType::isBuiltin — 检查它是否是内置类型
+添加备注
用户贡献的备注 1 note
tuncdan dot ozdemir dot peng at gmail dot com ¶
1 year ago
Editor note: This behaviour is due to BC concerns with PHP 7, and will likely be fixed in PHP 9.
2024-02-14
PHP 8.3
interface AnyType {}
interface Type2 {}
function test (AnyType|null $param) {}
The ReflectionParameter will return ReflectionNamedType, NOT ReflectionUnionType (null is ignored basically).
However, function test (AnyType|Type2|null $param) {}
will return ReflectionUnionType with 3 types, NOT 2 (null is not ignored this time).
To me, this is just wrong and logical error in PHP.
备份地址:http://www.lvesu.com/blog/php/class.reflectionnamedtype.php