From 6dd2aec011db09d286de11faeda490a3e718edb9 Mon Sep 17 00:00:00 2001 From: Vladimir Reznichenko Date: Mon, 14 May 2018 11:00:01 +0200 Subject: [PATCH] [minor]: SCA (#16269) * Php Inspections (EA Ultimate): minor code tweaks * Php Inspections (EA Ultimate): code style * Php Inspections (EA Ultimate): code style * Php Inspections (EA Ultimate): code style --- framework/db/ActiveRelationTrait.php | 30 +++++++++++++--------------- framework/db/oci/Schema.php | 2 +- framework/web/Request.php | 2 +- framework/web/Session.php | 8 +++----- 4 files changed, 19 insertions(+), 23 deletions(-) diff --git a/framework/db/ActiveRelationTrait.php b/framework/db/ActiveRelationTrait.php index 3297e2655d..5c196daa0e 100644 --- a/framework/db/ActiveRelationTrait.php +++ b/framework/db/ActiveRelationTrait.php @@ -353,24 +353,22 @@ trait ActiveRelationTrait } } } - } else { - if ($this->multiple) { - foreach ($primaryModels as $i => $primaryModel) { - foreach ($primaryModel[$primaryName] as $j => $m) { - if ($m instanceof ActiveRecordInterface) { - $m->populateRelation($name, $primaryModel); - } else { - $primaryModels[$i][$primaryName][$j][$name] = $primaryModel; - } + } elseif ($this->multiple) { + foreach ($primaryModels as $i => $primaryModel) { + foreach ($primaryModel[$primaryName] as $j => $m) { + if ($m instanceof ActiveRecordInterface) { + $m->populateRelation($name, $primaryModel); + } else { + $primaryModels[$i][$primaryName][$j][$name] = $primaryModel; } } - } else { - foreach ($primaryModels as $i => $primaryModel) { - if ($primaryModels[$i][$primaryName] instanceof ActiveRecordInterface) { - $primaryModels[$i][$primaryName]->populateRelation($name, $primaryModel); - } elseif (!empty($primaryModels[$i][$primaryName])) { - $primaryModels[$i][$primaryName][$name] = $primaryModel; - } + } + } else { + foreach ($primaryModels as $i => $primaryModel) { + if ($primaryModels[$i][$primaryName] instanceof ActiveRecordInterface) { + $primaryModels[$i][$primaryName]->populateRelation($name, $primaryModel); + } elseif (!empty($primaryModels[$i][$primaryName])) { + $primaryModels[$i][$primaryName][$name] = $primaryModel; } } } diff --git a/framework/db/oci/Schema.php b/framework/db/oci/Schema.php index 3f85de3315..2b317dc4e7 100644 --- a/framework/db/oci/Schema.php +++ b/framework/db/oci/Schema.php @@ -621,7 +621,7 @@ SQL; } else { $returnParams[$phName]['dataType'] = \PDO::PARAM_INT; } - $returnParams[$phName]['size'] = isset($columnSchemas[$name]) && isset($columnSchemas[$name]->size) ? $columnSchemas[$name]->size : -1; + $returnParams[$phName]['size'] = isset($columnSchemas[$name]->size) ? $columnSchemas[$name]->size : -1; $returning[] = $this->quoteColumnName($name); } $sql .= ' RETURNING ' . implode(', ', $returning) . ' INTO ' . implode(', ', array_keys($returnParams)); diff --git a/framework/web/Request.php b/framework/web/Request.php index d7c49773a4..acc5d02f61 100644 --- a/framework/web/Request.php +++ b/framework/web/Request.php @@ -937,7 +937,7 @@ class Request extends \yii\base\Request throw new InvalidConfigException('Unable to determine the path info of the current request.'); } - if (substr($pathInfo, 0, 1) === '/') { + if (strncmp($pathInfo, '/', 1) === 0) { $pathInfo = substr($pathInfo, 1); } diff --git a/framework/web/Session.php b/framework/web/Session.php index 16584ddac6..d1868211f2 100644 --- a/framework/web/Session.php +++ b/framework/web/Session.php @@ -814,12 +814,10 @@ class Session extends Component implements \IteratorAggregate, \ArrayAccess, \Co $_SESSION[$this->flashParam] = $counters; if (empty($_SESSION[$key])) { $_SESSION[$key] = [$value]; + } elseif (is_array($_SESSION[$key])) { + $_SESSION[$key][] = $value; } else { - if (is_array($_SESSION[$key])) { - $_SESSION[$key][] = $value; - } else { - $_SESSION[$key] = [$_SESSION[$key], $value]; - } + $_SESSION[$key] = [$_SESSION[$key], $value]; } }