Deprecated: Optional parameter $keys declared before required parameter $cms_id is implicitly treated as a required parameter in /home/www/dev/work/class/blog/CmsKey.php on line 75

Deprecated: Creation of dynamic property lvesu\lvesu\controller\blog\php::$title is deprecated in /home/www/dev/work/website/lvesu/class/controller/blog/php.php on line 28

Deprecated: Creation of dynamic property lvesu\lvesu\controller\blog\php::$outlink is deprecated in /home/www/dev/work/website/lvesu/template/blog/cms/php.manual.tpl on line 2

Deprecated: Creation of dynamic property lvesu\lvesu\controller\blog\php::$status is deprecated in /home/www/dev/work/website/lvesu/template/blog/index.head.php on line 2
PHP - Manual: ReflectionNamedType - 互联网笔记

略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: ReflectionNamedType

2025-04-28

ReflectionNamedType 类

(PHP 7 >= 7.1.0, PHP 8)

简介

类摘要

class ReflectionNamedType extends ReflectionType {
/* 方法 */
public getName(): string
public isBuiltin(): bool
/* 继承的方法 */
}

目录

添加备注

用户贡献的备注 1 note

up
-1
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.

官方地址:https://www.php.net/manual/en/class.reflectionnamedtype.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3