<?php
use MyORM\Attributes as ORM;
class Distillery
{
#[ORM\Column("string")]
private $name;
}
<?php
namespace MyORM\Attributes;
use Attribute;
#[Attribute]
class Column {
public function __construct(public string $type) { }
}
<?php
$rc = new \ReflectionClass(\Distillery::class);
$rp = $rc->getProperty('name');
foreach ($rp->getAttributes() as $attr) {
echo "Name: ", $attr->getName(), "\n";
var_dump($attr->getArguments());
var_dump($attr->*newInstance()*);
}
Name: MyORM\Attributes\Column
array(1) {
[0]=>
string(6) "string"
}
object(MyORM\Attributes\Column)#4 (1) {
["type"]=>
string(6) "string"
}