ReflectionProperty::getType

(PHP 7 >= 7.4.0)

ReflectionProperty::getTypeGets a property's type

Descrição

public ReflectionProperty::getType ( ) : ReflectionType|null

Gets the associated type of a property.

Parâmetros

Esta função não possui parâmetros.

Valor Retornado

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

Exemplos

Exemplo #1 ReflectionProperty::getType() example

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

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

O exemplo acima irá imprimir:

string

Veja Também