Skip to content

Commit b0d221c

Browse files
author
Oleksii Korshenko
committed
MAGETWO-49585: [GitHub] Add type declaration to setter methods of generated ExtensionAttribute classes #2451
- Fixes #2451 - fixed unit tests
1 parent 5e7c3b4 commit b0d221c

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

lib/internal/Magento/Framework/TestFramework/Unit/Helper/ObjectManager.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -162,15 +162,15 @@ public function getObject($className, array $arguments = [])
162162
$newObject = $reflectionClass->newInstanceArgs($constructArguments);
163163

164164
foreach (array_diff_key($arguments, $constructArguments) as $key => $value) {
165-
if ($reflectionClass->hasProperty($key)) {
166-
$reflectionProperty = $reflectionClass->getProperty($key);
167-
$reflectionProperty->setAccessible(true);
168-
$reflectionProperty->setValue($newObject, $value);
169-
} elseif ($reflectionClass->getParentClass() && $reflectionClass->getParentClass()->hasProperty($key)) {
170-
//catch use case when private property is declared in parent class
171-
$reflectionProperty = $reflectionClass->getParentClass()->getProperty($key);
172-
$reflectionProperty->setAccessible(true);
173-
$reflectionProperty->setValue($newObject, $value);
165+
$propertyReflectionClass = $reflectionClass;
166+
while ($propertyReflectionClass) {
167+
if ($propertyReflectionClass->hasProperty($key)) {
168+
$reflectionProperty = $propertyReflectionClass->getProperty($key);
169+
$reflectionProperty->setAccessible(true);
170+
$reflectionProperty->setValue($newObject, $value);
171+
break;
172+
}
173+
$propertyReflectionClass = $reflectionClass->getParentClass();
174174
}
175175
}
176176
return $newObject;

0 commit comments

Comments
 (0)