The ReflectionType class

(PHP 7, PHP 8)


The ReflectionType class reports information about a function's parameter/return type or a class's property type. The Reflection extension declares the following subtypes:

Sinopsis de la Clase

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

Historial de cambios

Versión Descripción
8.0.0 ReflectionType has become abstract and ReflectionType::isBuiltin() has been moved to ReflectionNamedType::isBuiltin().

Tabla de contenidos

add a note

User Contributed Notes 4 notes

4 years ago
For those who stumble on notice about ReflectionType::__toString() beeing deprecated, use method ReflectionType::getName() instead which is not yet documented.
Ondej Mirtes
3 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.
benjamin dot morel at gmail dot com
3 years ago
Known subclasses:

- ReflectionNamedType
- ReflectionUnionType
roland at mxchange dot org
4 years ago
I guess it is <?php ReflectionNamedType::getName(); ?> ?
To Top