mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-09-06 11:32:40 +00:00
unify null checks - avoid method call in favor of strict check
This commit is contained in:
parent
8428928fd6
commit
6cf147e8c8
35 changed files with 62 additions and 62 deletions
|
@ -513,7 +513,7 @@ class TranslateBehavior extends ModelBehavior {
|
|||
* @return mixed string or false
|
||||
*/
|
||||
protected function _getLocale(Model $Model) {
|
||||
if (!isset($Model->locale) || is_null($Model->locale)) {
|
||||
if (!isset($Model->locale) || $Model->locale === null) {
|
||||
$I18n = I18n::getInstance();
|
||||
$I18n->l10n->get(Configure::read('Config.language'));
|
||||
$Model->locale = $I18n->l10n->locale;
|
||||
|
@ -588,7 +588,7 @@ class TranslateBehavior extends ModelBehavior {
|
|||
|
||||
$this->_removeField($Model, $field);
|
||||
|
||||
if (is_null($association)) {
|
||||
if ($association === null) {
|
||||
if ($reset) {
|
||||
$this->runtime[$Model->alias]['fields'][] = $field;
|
||||
} else {
|
||||
|
@ -677,7 +677,7 @@ class TranslateBehavior extends ModelBehavior {
|
|||
|
||||
$this->_removeField($Model, $field);
|
||||
|
||||
if (!is_null($association) && (isset($Model->hasMany[$association]) || isset($Model->__backAssociation['hasMany'][$association]))) {
|
||||
if ($association !== null && (isset($Model->hasMany[$association]) || isset($Model->__backAssociation['hasMany'][$association]))) {
|
||||
$associations[] = $association;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -307,7 +307,7 @@ class TreeBehavior extends ModelBehavior {
|
|||
|
||||
extract($this->settings[$Model->alias]);
|
||||
|
||||
if (!is_null($overrideRecursive)) {
|
||||
if ($overrideRecursive !== null) {
|
||||
$recursive = $overrideRecursive;
|
||||
}
|
||||
if (!$order) {
|
||||
|
@ -353,7 +353,7 @@ class TreeBehavior extends ModelBehavior {
|
|||
public function generateTreeList(Model $Model, $conditions = null, $keyPath = null, $valuePath = null, $spacer = '_', $recursive = null) {
|
||||
$overrideRecursive = $recursive;
|
||||
extract($this->settings[$Model->alias]);
|
||||
if (!is_null($overrideRecursive)) {
|
||||
if ($overrideRecursive !== null) {
|
||||
$recursive = $overrideRecursive;
|
||||
}
|
||||
|
||||
|
@ -415,7 +415,7 @@ class TreeBehavior extends ModelBehavior {
|
|||
$id = $Model->id;
|
||||
}
|
||||
extract($this->settings[$Model->alias]);
|
||||
if (!is_null($overrideRecursive)) {
|
||||
if ($overrideRecursive !== null) {
|
||||
$recursive = $overrideRecursive;
|
||||
}
|
||||
$parentId = $Model->find('first', array('conditions' => array($Model->primaryKey => $id), 'fields' => array($parent), 'recursive' => -1));
|
||||
|
@ -448,7 +448,7 @@ class TreeBehavior extends ModelBehavior {
|
|||
$id = $Model->id;
|
||||
}
|
||||
extract($this->settings[$Model->alias]);
|
||||
if (!is_null($overrideRecursive)) {
|
||||
if ($overrideRecursive !== null) {
|
||||
$recursive = $overrideRecursive;
|
||||
}
|
||||
$result = $Model->find('first', array('conditions' => array($Model->escapeField() => $id), 'fields' => array($left, $right), 'recursive' => $recursive));
|
||||
|
@ -817,7 +817,7 @@ class TreeBehavior extends ModelBehavior {
|
|||
))));
|
||||
|
||||
foreach ($Model->find('all', array('conditions' => $scope, 'recursive' => 0)) as $instance) {
|
||||
if (is_null($instance[$Model->alias][$left]) || is_null($instance[$Model->alias][$right])) {
|
||||
if ($instance[$Model->alias][$left] === null || $instance[$Model->alias][$right] === null) {
|
||||
$errors[] = array('node', $instance[$Model->alias][$Model->primaryKey],
|
||||
'has invalid left or right values');
|
||||
} elseif ($instance[$Model->alias][$left] == $instance[$Model->alias][$right]) {
|
||||
|
|
|
@ -366,7 +366,7 @@ class CakeSession {
|
|||
if (!self::start()) {
|
||||
return false;
|
||||
}
|
||||
if (is_null($name)) {
|
||||
if ($name === null) {
|
||||
return self::_returnSessionVars();
|
||||
}
|
||||
if (empty($name)) {
|
||||
|
|
|
@ -657,7 +657,7 @@ class Mysql extends DboSource {
|
|||
* @return string Formatted length part of an index field
|
||||
*/
|
||||
protected function _buildIndexSubPart($lengths, $column) {
|
||||
if (is_null($lengths)) {
|
||||
if ($lengths === null) {
|
||||
return '';
|
||||
}
|
||||
if (!isset($lengths[$column])) {
|
||||
|
|
|
@ -748,11 +748,11 @@ class Postgres extends DboSource {
|
|||
|
||||
switch ($type) {
|
||||
case 'bool':
|
||||
$resultRow[$table][$column] = is_null($row[$index]) ? null : $this->boolean($row[$index]);
|
||||
$resultRow[$table][$column] = $row[$index] === null ? null : $this->boolean($row[$index]);
|
||||
break;
|
||||
case 'binary':
|
||||
case 'bytea':
|
||||
$resultRow[$table][$column] = is_null($row[$index]) ? null : stream_get_contents($row[$index]);
|
||||
$resultRow[$table][$column] = $row[$index] === null ? null : stream_get_contents($row[$index]);
|
||||
break;
|
||||
default:
|
||||
$resultRow[$table][$column] = $row[$index];
|
||||
|
|
|
@ -357,7 +357,7 @@ class Sqlite extends DboSource {
|
|||
foreach ($this->map as $col => $meta) {
|
||||
list($table, $column, $type) = $meta;
|
||||
$resultRow[$table][$column] = $row[$col];
|
||||
if ($type === 'boolean' && !is_null($row[$col])) {
|
||||
if ($type === 'boolean' && $row[$col] !== null) {
|
||||
$resultRow[$table][$column] = $this->boolean($resultRow[$table][$column]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -615,7 +615,7 @@ class Sqlserver extends DboSource {
|
|||
continue;
|
||||
}
|
||||
$resultRow[$table][$column] = $row[$col];
|
||||
if ($type === 'boolean' && !is_null($row[$col])) {
|
||||
if ($type === 'boolean' && $row[$col] !== null) {
|
||||
$resultRow[$table][$column] = $this->boolean($resultRow[$table][$column]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1035,7 +1035,7 @@ class DboSource extends DataSource {
|
|||
$recursive = $queryData['recursive'];
|
||||
}
|
||||
|
||||
if (!is_null($recursive)) {
|
||||
if ($recursive !== null) {
|
||||
$_recursive = $model->recursive;
|
||||
$model->recursive = $recursive;
|
||||
}
|
||||
|
@ -1123,7 +1123,7 @@ class DboSource extends DataSource {
|
|||
}
|
||||
}
|
||||
|
||||
if (!is_null($recursive)) {
|
||||
if ($recursive !== null) {
|
||||
$model->recursive = $_recursive;
|
||||
}
|
||||
return $resultSet;
|
||||
|
|
|
@ -2693,7 +2693,7 @@ class Model extends Object implements CakeEventListener {
|
|||
$this->id = $this->getID();
|
||||
|
||||
$query = $this->buildQuery($type, $query);
|
||||
if (is_null($query)) {
|
||||
if ($query === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue