- var_dump: documentation ( source)
<?php
interface factory
{
public static function new(): factory;
}
#[Value]
class Value
{
public int $value;
public function __construct(int $value)
{
$this->value = $value;
}
}
#[Value(value: 42)]
class One implements factory
{
public static function new(): One
{
return new One;
}
}
#[Value(value: 2)]
class Two implements factory
{
public static function new(): Two
{
return new Two;
}
}
#[Value(value: 3)]
class Three implements factory
{
public static function new(): Three
{
return new Three;
}
}
$arrayOfClasses = [One::new(), Two::new(), Three::new()];
function dumpAttributeData(ReflectionClass $reflection)
{
$attributes = $reflection->getAttributes();
foreach ($attributes as $attribute) {
var_dump($attribute->getName());
var_dump($attribute->getArguments());
}
}
foreach ($arrayOfClasses as $class) {
dumpAttributeData(new ReflectionClass($class::class));
}