ReflectionProperty::hasType
PHP function
Edit on GitHub ✎
(PHP 7 >= 7.4.0, PHP 8)
Checks if property has a type
Description
ReflectionProperty::hasType(): bool
Checks if the property has a type associated with it.
Parameters Parameters
Return Values
true if a type is specified, false otherwise.
Examples
ReflectionProperty::hasType example
php
<?php
class User
{
public string $name;
}
$rp = new ReflectionProperty('User', 'name');
var_dump($rp->hasType());
?>The above example will output:
output
bool(true)See Also
ReflectionProperty::getTypeReflectionProperty::isInitialized