feature: обработал доступ к приватному свойству
расширил тест
This commit is contained in:
parent
59f37226ee
commit
d7facd9cc7
@ -320,14 +320,17 @@ class Data2DtoConverter
|
|||||||
|
|
||||||
private function getValue(object $object, \ReflectionProperty $property)
|
private function getValue(object $object, \ReflectionProperty $property)
|
||||||
{
|
{
|
||||||
if (!$property->isInitialized($object)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$property->isPublic()) {
|
if (!$property->isPublic()) {
|
||||||
$property->setAccessible(true);
|
$property->setAccessible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!$property->isInitialized($object)) {
|
||||||
|
if (!$property->isPublic()) {
|
||||||
|
$property->setAccessible(false);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
$value = $property->getValue($object);
|
$value = $property->getValue($object);
|
||||||
|
|
||||||
if (!$property->isPublic()) {
|
if (!$property->isPublic()) {
|
||||||
|
@ -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…
Reference in New Issue
Block a user