Skip to content

Commit feb637b

Browse files
Fix #19354: Reuse Validator::getAttributeNames() in AttributeTypecastBehavior::detectAttributeTypes()
1 parent 70df221 commit feb637b

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ Yii Framework 2 Change Log
6666
- Enh #19401: Delay `exit(1)` in `yii\base\ErrorHandler::handleFatalError` (arrilot)
6767
- Enh #19416: Update and improve configurations for `yii\console\controllers\MessageController` (WinterSilence)
6868
- Enh #19420: Update list of JS callbacks in `yii\widgets\MaskedInput` (WinterSilence)
69+
- Chg #19354: Reuse `Validator::getAttributeNames()` in `AttributeTypecastBehavior::detectAttributeTypes()` (WinterSilence)
6970
- Enh #19437: Add support to specify request port by trusted proxies in `\yii\web\Request::getServerPort()` (rhertogh)
7071

7172

behaviors/AttributeTypecastBehavior.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,9 +293,7 @@ protected function detectAttributeTypes()
293293
}
294294

295295
if ($type !== null) {
296-
foreach ((array) $validator->attributes as $attribute) {
297-
$attributeTypes[ltrim($attribute, '!')] = $type;
298-
}
296+
$attributeTypes += array_fill_keys($validator->getAttributeNames(), $type);
299297
}
300298
}
301299

0 commit comments

Comments
 (0)