[minor] SCA (#16464)

* Php Inspections (EA Ultimate): new findings

* Php Inspections (EA Ultimate): dealing with older PHP versions compatibility
This commit is contained in:
Vladimir Reznichenko
2018-07-01 00:04:48 +02:00
committed by Alexander Makarov
parent e55b3e0ba1
commit 84c55b468a
2 changed files with 3 additions and 6 deletions

View File

@ -504,10 +504,7 @@ trait ActiveRelationTrait
// composite keys // composite keys
// ensure keys of $this->link are prefixed the same way as $attributes // ensure keys of $this->link are prefixed the same way as $attributes
$prefixedLink = array_combine( $prefixedLink = array_combine($attributes, $this->link);
$attributes,
array_values($this->link)
);
foreach ($models as $model) { foreach ($models as $model) {
$v = []; $v = [];
foreach ($prefixedLink as $attribute => $link) { foreach ($prefixedLink as $attribute => $link) {

View File

@ -1572,9 +1572,9 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface
throw new InvalidCallException('Unable to link models: the primary key of ' . get_class($primaryModel) . ' is null.'); throw new InvalidCallException('Unable to link models: the primary key of ' . get_class($primaryModel) . ' is null.');
} }
if (is_array($foreignModel->$fk)) { // relation via array valued attribute if (is_array($foreignModel->$fk)) { // relation via array valued attribute
$foreignModel->$fk = array_merge($foreignModel->$fk, [$value]); $foreignModel->{$fk}[] = $value;
} else { } else {
$foreignModel->$fk = $value; $foreignModel->{$fk} = $value;
} }
} }
$foreignModel->save(false); $foreignModel->save(false);