ReflectionProperty::getType

(PHP 7 >= 7.4.0, PHP 8)

ReflectionProperty::getTypeGets a property's type

Beschreibung

publicReflectionProperty::getType(): ?ReflectionType

Gets the associated type of a property.

Parameter-Liste

Diese Funktion besitzt keine Parameter.

Rückgabewerte

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

Beispiele

Beispiel #1 ReflectionProperty::getType() example

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

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

Das oben gezeigte Beispiel erzeugt folgende Ausgabe:

string

Siehe auch

To Top