PHP Velho Oeste 2024

The ReflectionNamedType class

(PHP 7 >= 7.1.0, PHP 8)

Introdução

Resumo da classe

class ReflectionNamedType extends ReflectionType {
/* Métodos */
public getName(): string
public isBuiltin(): bool
/* Métodos herdados */
}

Índice

add a note

User Contributed Notes 1 note

up
0
tuncdan dot ozdemir dot peng at gmail dot com
12 days ago
2024-02-14

Editor note: This behaviour is due to BC concerns with PHP 7, and will likely be fixed in PHP 9.

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.
To Top