Skip to content

Commit 01a7b8e

Browse files
authored
ENGCOM-5593: Replace annoying multi-line warning with short message + context #23894
2 parents a2e378e + 0f2c611 commit 01a7b8e

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

app/code/Magento/Eav/Model/ResourceModel/ReadHandler.php

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,27 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
67
namespace Magento\Eav\Model\ResourceModel;
78

9+
use Exception;
810
use Magento\Eav\Model\Config;
11+
use Magento\Eav\Model\Entity\Attribute\AbstractAttribute;
912
use Magento\Framework\DataObject;
1013
use Magento\Framework\DB\Select;
1114
use Magento\Framework\DB\Sql\UnionExpression;
1215
use Magento\Framework\EntityManager\MetadataPool;
1316
use Magento\Framework\EntityManager\Operation\AttributeInterface;
17+
use Magento\Framework\Exception\ConfigurationMismatchException;
18+
use Magento\Framework\Exception\LocalizedException;
1419
use Magento\Framework\Model\Entity\ScopeInterface;
1520
use Magento\Framework\Model\Entity\ScopeResolver;
1621
use Psr\Log\LoggerInterface;
1722

1823
/**
1924
* EAV read handler
25+
*
26+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2027
*/
2128
class ReadHandler implements AttributeInterface
2229
{
@@ -63,7 +70,7 @@ public function __construct(
6370
*
6471
* @param string $entityType
6572
* @return \Magento\Eav\Api\Data\AttributeInterface[]
66-
* @throws \Exception if for unknown entity type
73+
* @throws Exception if for unknown entity type
6774
* @deprecated Not used anymore
6875
* @see ReadHandler::getEntityAttributes
6976
*/
@@ -80,7 +87,7 @@ protected function getAttributes($entityType)
8087
* @param string $entityType
8188
* @param DataObject $entity
8289
* @return \Magento\Eav\Api\Data\AttributeInterface[]
83-
* @throws \Exception if for unknown entity type
90+
* @throws Exception if for unknown entity type
8491
*/
8592
private function getEntityAttributes(string $entityType, DataObject $entity): array
8693
{
@@ -111,9 +118,9 @@ protected function getContextVariables(ScopeInterface $scope)
111118
* @param array $entityData
112119
* @param array $arguments
113120
* @return array
114-
* @throws \Exception
115-
* @throws \Magento\Framework\Exception\ConfigurationMismatchException
116-
* @throws \Magento\Framework\Exception\LocalizedException
121+
* @throws Exception
122+
* @throws ConfigurationMismatchException
123+
* @throws LocalizedException
117124
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
118125
*/
119126
public function execute($entityType, $entityData, $arguments = [])
@@ -129,7 +136,7 @@ public function execute($entityType, $entityData, $arguments = [])
129136
$attributesMap = [];
130137
$selects = [];
131138

132-
/** @var \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute */
139+
/** @var AbstractAttribute $attribute */
133140
foreach ($this->getEntityAttributes($entityType, new DataObject($entityData)) as $attribute) {
134141
if (!$attribute->isStatic()) {
135142
$attributeTables[$attribute->getBackend()->getTable()][] = $attribute->getAttributeId();
@@ -170,8 +177,11 @@ public function execute($entityType, $entityData, $arguments = [])
170177
$entityData[$attributesMap[$attributeValue['attribute_id']]] = $attributeValue['value'];
171178
} else {
172179
$this->logger->warning(
173-
"Attempt to load value of nonexistent EAV attribute '{$attributeValue['attribute_id']}'
174-
for entity type '$entityType'."
180+
"Attempt to load value of nonexistent EAV attribute",
181+
[
182+
'attribute_id' => $attributeValue['attribute_id'],
183+
'entity_type' => $entityType
184+
]
175185
);
176186
}
177187
}
@@ -184,8 +194,9 @@ public function execute($entityType, $entityData, $arguments = [])
184194
*
185195
* @param Select[] $selects
186196
* @param array $identifiers
197+
* @return void
187198
*/
188-
private function applyIdentifierForSelects(array $selects, array $identifiers)
199+
private function applyIdentifierForSelects(array $selects, array $identifiers): void
189200
{
190201
foreach ($selects as $select) {
191202
foreach ($identifiers as $identifier) {

0 commit comments

Comments
 (0)