ReflectionProperty::getType

(PHP 7 >= 7.4.0)

ReflectionProperty::getTypeGets a property's type

Descrierea

public ReflectionProperty::getType ( ) : ReflectionType|null

Gets the associated type of a property.

Parametri

Această funcție nu are parametri.

Valorile întoarse

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

Exemple

Example #1 ReflectionProperty::getType() example

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

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

Exemplul de mai sus va afișa:

string

A se vedea și