La classe ReflectionType

(PHP 7, PHP 8)

Introduction

La classe ReflectionType relate les informations à propos du type de retour d'une fonction. L'extension Reflection déclare les sous-types suivants :

Synopsis de la classe

abstract class ReflectionType implements Stringable {
/* Méthodes */
public allowsNull(): bool
public __toString(): string
}

Historique

Version Description
8.0.0 ReflectionType est devenue abstraite et ReflectionType::isBuiltin() a été déplacée vers ReflectionNamedType::isBuiltin().

Sommaire

add a note

User Contributed Notes 2 notes

up
42
1franck
4 years ago
For those who stumble on notice about ReflectionType::__toString() beeing deprecated, use method ReflectionNamedType::getName() instead which is not yet documented.
up
15
Ondej Mirtes
4 years ago
Method ReflectionType::getName() does not exist. This may have been virtually true in the past but not anymore. It exists on ReflectionNamedType which used to be the only child class of ReflectionType. So you could have kind of relied on that.

But in PHP 8 there's also ReflectionUnionType which doesn't have the getName() method. So in order to support PHP 8, you need to support both ReflectionNamedType and ReflectionUnionType.
To Top