feature: обработал доступ к приватному свойству

расширил тест
This commit is contained in:
Rinsvent 2022-01-03 23:00:11 +07:00
parent 59f37226ee
commit d7facd9cc7
2 changed files with 19 additions and 4 deletions

View File

@ -320,14 +320,17 @@ class Data2DtoConverter
private function getValue(object $object, \ReflectionProperty $property)
{
if (!$property->isInitialized($object)) {
return null;
}
if (!$property->isPublic()) {
$property->setAccessible(true);
}
if (!$property->isInitialized($object)) {
if (!$property->isPublic()) {
$property->setAccessible(false);
}
return null;
}
$value = $property->getValue($object);
if (!$property->isPublic()) {

View File

@ -18,4 +18,16 @@ class HelloRequest
public BuyRequest $buy;
#[DTOMeta(class: Bar::class)]
public BarInterface $bar;
private BuyRequest $buy2;
public function getBuy2(): BuyRequest
{
return $this->buy2;
}
public function setBuy2(BuyRequest $buy2): void
{
$this->buy2 = $buy2;
}
}