PHP 8.5.0 Alpha 4 available for testing

The ReflectionType class

(PHP 7, PHP 8)

Introduction

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:

Class synopsis

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

Changelog

Version Description
8.0.0 ReflectionType has become abstract and ReflectionType::isBuiltin() has been moved to ReflectionNamedType::isBuiltin().

Table of Contents

add a note

User Contributed Notes 2 notes

up
43
1franck
5 years ago
For those who stumble on notice about ReflectionType::__toString() beeing deprecated, use method ReflectionNamedType::getName() instead which is not yet documented.
up
16
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
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy