PHP Conference Japan 2024

ReflectionNamedType 類別

(PHP 7 >= 7.1.0, PHP 8)

簡介

類別概要

類別 ReflectionNamedType 繼承自 ReflectionType {
/* 方法 */
公開 getName(): 字串
/* 繼承的方法 */
}

目錄

新增註釋

使用者貢獻的註釋 1 則註釋

tuncdan dot ozdemir dot peng at gmail dot com
9 個月前
編者註:此行為是由於 PHP 7 的向下相容性考量,可能會在 PHP 9 中修復。

2024-02-14

PHP 8.3

interface AnyType {}
interface Type2 {}

function test (AnyType|null $param) {}

ReflectionParameter 將返回 ReflectionNamedType,而不是 ReflectionUnionType(基本上忽略 null)。

然而,function test (AnyType|Type2|null $param) {}

將返回具有 3 種類型而不是 2 種的 ReflectionUnionType(這次不忽略 null)。

對我來說,這只是 PHP 中的錯誤和邏輯錯誤。
To Top