diff --git a/src/AbstractActiveRecord.php b/src/AbstractActiveRecord.php index 1c4d69d49..7855a68d8 100644 --- a/src/AbstractActiveRecord.php +++ b/src/AbstractActiveRecord.php @@ -823,7 +823,7 @@ public function updateCounters(array $counters): bool foreach ($counters as $name => $value) { $value += $this->getAttribute($name) ?? 0; - $this->setAttribute($name, $value); + $this->populateAttribute($name, $value); $this->oldAttributes[$name] = $value; } @@ -1184,7 +1184,7 @@ protected function updateInternal(array $attributes = null): int throw new StaleObjectException('The object being updated is outdated.'); } - $this->setAttribute($lock, $lockValue); + $this->populateAttribute($lock, $lockValue); } else { $rows = $this->updateAll($values, $condition); } @@ -1212,12 +1212,11 @@ private function bindModels( /** * relation via array valued attribute - * - * @psalm-suppress MixedArrayAssignment */ - if (is_array($foreignModel->getAttribute($fk))) { + if (is_array($fkValue = $foreignModel->getAttribute($fk))) { /** @psalm-var mixed */ - $foreignModel->{$fk}[] = $value; + $fkValue[] = $value; + $foreignModel->setAttribute($fk, $fkValue); } else { $foreignModel->setAttribute($fk, $value); }