Skip to content

Commit a6ab66c

Browse files
committed
MAGETWO-56206: API - inconsistency in the Magento response data types
- Force extension_attributes to empty object instead of empty array - Remove unused imports and docblocks
1 parent 15d3681 commit a6ab66c

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

lib/internal/Magento/Framework/Reflection/DataObjectProcessor.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
use Magento\Framework\Api\CustomAttributesDataInterface;
99
use Magento\Framework\Phrase;
10-
use Zend\Code\Reflection\MethodReflection;
1110

1211
/**
1312
* Data object processor for array serialization using class reflection
@@ -75,7 +74,6 @@ public function buildOutputDataArray($dataObject, $dataObjectType)
7574
$methods = $this->methodsMapProcessor->getMethodsMap($dataObjectType);
7675
$outputData = [];
7776

78-
/** @var MethodReflection $method */
7977
foreach (array_keys($methods) as $methodName) {
8078
if (!$this->methodsMapProcessor->isMethodValidForDataField($dataObjectType, $methodName)) {
8179
continue;
@@ -99,7 +97,8 @@ public function buildOutputDataArray($dataObject, $dataObjectType)
9997
if ($key === CustomAttributesDataInterface::CUSTOM_ATTRIBUTES) {
10098
$value = $this->customAttributesProcessor->buildOutputDataArray($dataObject, $dataObjectType);
10199
} elseif ($key === "extension_attributes") {
102-
$value = $this->extensionAttributesProcessor->buildOutputDataArray($value, $returnType);
100+
$attributeArray = $this->extensionAttributesProcessor->buildOutputDataArray($value, $returnType);
101+
$value = empty($attributeArray) ? new \Magento\Framework\DataObject() : $attributeArray;
103102
} else {
104103
if (is_object($value) && !($value instanceof Phrase)) {
105104
$value = $this->buildOutputDataArray($value, $returnType);

0 commit comments

Comments
 (0)