Overview
KB
Technical FAQ
PHP Manual
CSS2 Manual
HTML Manual
JS Guide
JS Reference
PhpDock Manual
Nu-Coder Manual
PhpExpress Manual
PHP Joomla
Development
Learn PHP
 
<ReflectionProperty::getSettableTypeReflectionProperty::getValue>
^ReflectionPropertyLast updated: Mon, 26 Oct 2026

ReflectionProperty::getType

(PHP 7 >= 7.4.0, PHP 8)

ReflectionProperty::getType — Gets a property's type

Description

public function ReflectionProperty::getType(): ?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


<ReflectionProperty::getSettableTypeReflectionProperty::getValue>
^ReflectionPropertyLast updated: Mon, 26 Oct 2026