PHP 8.5.0 Beta 1 available for testing

Voting

: min(two, one)?
(Example: nine)

The Note You're Voting On

wow-apps.pro
5 years ago
<?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"
* ""
*/

<< Back to user notes page

To Top