ReflectionProperty::getType

(PHP 7 >= 7.4.0, PHP 8)

ReflectionProperty::getTypeGets a property's type

Descripción

publicReflectionProperty::getType(): ?ReflectionType

Gets the associated type of a property.

Parámetros

Esta función no tiene parámetros.

Valores devueltos

Returns a ReflectionType if the property has a type, and null otherwise.

Ejemplos

Ejemplo #1 ReflectionProperty::getType() example

<?php
class User
{
public
string $name;
}

$rp = new ReflectionProperty('User', 'name');
echo
$rp->getType()->getName();
?>

El resultado del ejemplo sería:

string

Ver también

To Top