<?php
// How to get property type? For example for testing:
class Foo
{
private int $num;
private bool $isPositive;
private $notes;
}
$reflection = new \ReflectionClass(Foo::class);
$classProperties = $reflection->getProperties(\ReflectionProperty::IS_PRIVATE);
foreach ($classProperties as $classProperty) {
var_dump((string) $classProperty->getType());
}
/**
* Result:
* "int"
* "bool"
* ""
*/