LoopRun Barcelona 2020

ReflectionProperty::getType

(PHP 7 >= 7.4.0)

ReflectionProperty::getTypeGets a property's type

Description

public ReflectionProperty::getType ( void ) : ?ReflectionType

Gets the associated type of a property.

Parameters

This function has no parameters.

Return Values

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

Examples

Example #1 ReflectionProperty::getType() example

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

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

The above example will output:

string

See Also

add a note add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top