PHP 7.4.22 Released!

The ReflectionType class

(PHP 7, PHP 8)

Introdução

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

Sinopse da classe

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

Changelog

Versão Descrição
8.0.0 ReflectionType has become abstract and ReflectionType::isBuiltin() has been moved to ReflectionNamedType::isBuiltin().

Índice

add a note add a note

User Contributed Notes 4 notes

up
30
1franck
1 year ago
For those who stumble on notice about ReflectionType::__toString() beeing deprecated, use method ReflectionType::getName() instead which is not yet documented.
up
9
Ondej Mirtes
10 months 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.
up
2
roland at mxchange dot org
1 year ago
I guess it is <?php ReflectionNamedType::getName(); ?> ?
up
2
benjamin dot morel at gmail dot com
10 months ago
Known subclasses:

- ReflectionNamedType
- ReflectionUnionType
To Top