In my humble opinion, when the entity has the magic __get and/or __set methods and the @property... declaration, the ObjectHelpers::getMagicProperties() should also return them.
/**
* @property-read string $createdAt
* @property-read string $id
*/
class PersonEntity
{
protected array $data = [];
public function __construct(array $data)
{
$uuid = \Ramsey\Uuid\Rfc4122\UuidV7::fromBytes($data['id']);
$this->data['id'] = $uuid->toString();
$this->data['createdAt'] = $uuid->getDateTime();
}
public function __get(string $name)
{
if (isset($this->data[$name]) !== true) {
throw new InvalidArgumentException();
}
return $this->data[$name];
}
}
|
$uname = ucfirst($name); |
|
$write = $type !== '-read' |
|
&& $rc->hasMethod($nm = 'set' . $uname) |
|
&& ($rm = $rc->getMethod($nm))->name === $nm && !$rm->isPrivate() && !$rm->isStatic(); |
|
$read = $type !== '-write' |
|
&& ($rc->hasMethod($nm = 'get' . $uname) || $rc->hasMethod($nm = 'is' . $uname)) |
|
&& ($rm = $rc->getMethod($nm))->name === $nm && !$rm->isPrivate() && !$rm->isStatic(); |
|
|
|
if ($read || $write) { |
|
$props[$name] = $read << 0 | ($nm[0] === 'g') << 1 | $rm->returnsReference() << 2 | $write << 3 | ($type === '-deprecated') << 4; |
|
} |
In my humble opinion, when the entity has the magic
__getand/or__setmethods and the@property...declaration, theObjectHelpers::getMagicProperties()should also return them.utils/src/Utils/ObjectHelpers.php
Lines 144 to 154 in 17932ce