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

расширил тест
master v0.0.17
Rinsvent 3 years ago
parent 59f37226ee
commit d7facd9cc7
  1. 9
      src/Data2DtoConverter.php
  2. 12
      tests/unit/Converter/fixtures/FillTest/HelloRequest.php

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

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

Loading…
Cancel
Save