Skip to content

Commit 44a2149

Browse files
committed
ENGCOM-3814: Static test fix.
1 parent 1c464c2 commit 44a2149

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

app/code/Magento/Eav/Model/Attribute/Data/AbstractData.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ public function setRequestScope($scope)
143143

144144
/**
145145
* Set scope visibility
146+
*
146147
* Search value only in scope or search value in scope and global
147148
*
148149
* @param bool $flag
@@ -296,7 +297,7 @@ protected function _applyOutputFilter($value)
296297
* Validate value by attribute input validation rule
297298
*
298299
* @param string $value
299-
* @return string|true
300+
* @return array|true
300301
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
301302
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
302303
*/

app/code/Magento/Eav/Model/Attribute/Data/Text.php

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,20 +72,17 @@ public function validateValue($value)
7272
return true;
7373
}
7474

75-
if (empty($value) && $value !== '0' && $attribute->getDefaultValue() == NULL) {
75+
if (empty($value) && $value !== '0' && $attribute->getDefaultValue() === null) {
7676
$label = __($attribute->getStoreLabel());
7777
$errors[] = __('"%1" is a required value.', $label);
7878
}
7979

80-
$result = $this->validateLength($attribute, $value);
81-
if (count($result) !== 0) {
82-
$errors = array_merge($errors, $result);
83-
}
80+
$validateLengthResult = $this->validateLength($attribute, $value);
81+
$errors = array_merge($errors, $validateLengthResult);
82+
83+
$validateInputRuleResult = $this->validateInputRule($value);
84+
$errors = array_merge($errors, $validateInputRuleResult);
8485

85-
$result = $this->_validateInputRule($value);
86-
if ($result !== true) {
87-
$errors = array_merge($errors, $result);
88-
}
8986
if (count($errors) == 0) {
9087
return true;
9188
}
@@ -141,7 +138,7 @@ public function outputValue($format = \Magento\Eav\Model\AttributeDataFactory::O
141138
* @param string $value
142139
* @return array errors
143140
*/
144-
private function validateLength(\Magento\Eav\Model\Attribute $attribute, $value): array
141+
private function validateLength(\Magento\Eav\Model\Attribute $attribute, string $value): array
145142
{
146143
$errors = [];
147144
$length = $this->_string->strlen(trim($value));
@@ -162,4 +159,16 @@ private function validateLength(\Magento\Eav\Model\Attribute $attribute, $value)
162159

163160
return $errors;
164161
}
162+
163+
/**
164+
* Validate value by attribute input validation rule.
165+
*
166+
* @param string $value
167+
* @return array
168+
*/
169+
private function validateInputRule(string $value): array
170+
{
171+
$result = $this->_validateInputRule($value);
172+
return \is_array($result) ? $result : [];
173+
}
165174
}

0 commit comments

Comments
 (0)