mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge pull request #1533 from dereuromark/master-null-checks
unify null checks - avoid method call in favor of strict check
This commit is contained in:
commit
005699eb49
37 changed files with 74 additions and 74 deletions
|
@ -407,7 +407,7 @@ class ControllerTask extends BakeTask {
|
||||||
* @return array Set of controllers
|
* @return array Set of controllers
|
||||||
*/
|
*/
|
||||||
public function listAll($useDbConfig = null) {
|
public function listAll($useDbConfig = null) {
|
||||||
if (is_null($useDbConfig)) {
|
if ($useDbConfig === null) {
|
||||||
$useDbConfig = $this->connection;
|
$useDbConfig = $this->connection;
|
||||||
}
|
}
|
||||||
$this->__tables = $this->Model->getAllTables($useDbConfig);
|
$this->__tables = $this->Model->getAllTables($useDbConfig);
|
||||||
|
|
|
@ -219,7 +219,7 @@ class FixtureTask extends BakeTask {
|
||||||
}
|
}
|
||||||
|
|
||||||
$tableInfo = $data['tables'][$useTable];
|
$tableInfo = $data['tables'][$useTable];
|
||||||
if (is_null($modelImport)) {
|
if ($modelImport === null) {
|
||||||
$schema = $this->_generateSchema($tableInfo);
|
$schema = $this->_generateSchema($tableInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -661,7 +661,7 @@ class AuthComponent extends Component {
|
||||||
* @return string Redirect URL
|
* @return string Redirect URL
|
||||||
*/
|
*/
|
||||||
public function redirectUrl($url = null) {
|
public function redirectUrl($url = null) {
|
||||||
if (!is_null($url)) {
|
if ($url !== null) {
|
||||||
$redir = $url;
|
$redir = $url;
|
||||||
$this->Session->write('Auth.redirect', $redir);
|
$this->Session->write('Auth.redirect', $redir);
|
||||||
} elseif ($this->Session->check('Auth.redirect')) {
|
} elseif ($this->Session->check('Auth.redirect')) {
|
||||||
|
|
|
@ -219,7 +219,7 @@ class CookieComponent extends Component {
|
||||||
$this->read();
|
$this->read();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_null($encrypt)) {
|
if ($encrypt === null) {
|
||||||
$encrypt = true;
|
$encrypt = true;
|
||||||
}
|
}
|
||||||
$this->_encrypted = $encrypt;
|
$this->_encrypted = $encrypt;
|
||||||
|
@ -262,7 +262,7 @@ class CookieComponent extends Component {
|
||||||
if (empty($this->_values[$this->name])) {
|
if (empty($this->_values[$this->name])) {
|
||||||
$this->_values[$this->name] = array();
|
$this->_values[$this->name] = array();
|
||||||
}
|
}
|
||||||
if (is_null($key)) {
|
if ($key === null) {
|
||||||
return $this->_values[$this->name];
|
return $this->_values[$this->name];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -387,7 +387,7 @@ class CookieComponent extends Component {
|
||||||
* @return integer Unix timestamp
|
* @return integer Unix timestamp
|
||||||
*/
|
*/
|
||||||
protected function _expire($expires = null) {
|
protected function _expire($expires = null) {
|
||||||
if (is_null($expires)) {
|
if ($expires === null) {
|
||||||
return $this->_expires;
|
return $this->_expires;
|
||||||
}
|
}
|
||||||
$this->_reset = $this->_expires;
|
$this->_reset = $this->_expires;
|
||||||
|
|
|
@ -228,7 +228,7 @@ class CakePlugin {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function unload($plugin = null) {
|
public static function unload($plugin = null) {
|
||||||
if (is_null($plugin)) {
|
if ($plugin === null) {
|
||||||
self::$_plugins = array();
|
self::$_plugins = array();
|
||||||
} else {
|
} else {
|
||||||
unset(self::$_plugins[$plugin]);
|
unset(self::$_plugins[$plugin]);
|
||||||
|
|
|
@ -161,7 +161,7 @@ class I18n {
|
||||||
$_this->_lang = $lang;
|
$_this->_lang = $lang;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_null($domain)) {
|
if ($domain === null) {
|
||||||
$domain = self::$defaultDomain;
|
$domain = self::$defaultDomain;
|
||||||
}
|
}
|
||||||
if ($domain === '') {
|
if ($domain === '') {
|
||||||
|
|
|
@ -513,7 +513,7 @@ class TranslateBehavior extends ModelBehavior {
|
||||||
* @return mixed string or false
|
* @return mixed string or false
|
||||||
*/
|
*/
|
||||||
protected function _getLocale(Model $Model) {
|
protected function _getLocale(Model $Model) {
|
||||||
if (!isset($Model->locale) || is_null($Model->locale)) {
|
if (!isset($Model->locale) || $Model->locale === null) {
|
||||||
$I18n = I18n::getInstance();
|
$I18n = I18n::getInstance();
|
||||||
$I18n->l10n->get(Configure::read('Config.language'));
|
$I18n->l10n->get(Configure::read('Config.language'));
|
||||||
$Model->locale = $I18n->l10n->locale;
|
$Model->locale = $I18n->l10n->locale;
|
||||||
|
@ -588,7 +588,7 @@ class TranslateBehavior extends ModelBehavior {
|
||||||
|
|
||||||
$this->_removeField($Model, $field);
|
$this->_removeField($Model, $field);
|
||||||
|
|
||||||
if (is_null($association)) {
|
if ($association === null) {
|
||||||
if ($reset) {
|
if ($reset) {
|
||||||
$this->runtime[$Model->alias]['fields'][] = $field;
|
$this->runtime[$Model->alias]['fields'][] = $field;
|
||||||
} else {
|
} else {
|
||||||
|
@ -677,7 +677,7 @@ class TranslateBehavior extends ModelBehavior {
|
||||||
|
|
||||||
$this->_removeField($Model, $field);
|
$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;
|
$associations[] = $association;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -307,7 +307,7 @@ class TreeBehavior extends ModelBehavior {
|
||||||
|
|
||||||
extract($this->settings[$Model->alias]);
|
extract($this->settings[$Model->alias]);
|
||||||
|
|
||||||
if (!is_null($overrideRecursive)) {
|
if ($overrideRecursive !== null) {
|
||||||
$recursive = $overrideRecursive;
|
$recursive = $overrideRecursive;
|
||||||
}
|
}
|
||||||
if (!$order) {
|
if (!$order) {
|
||||||
|
@ -353,7 +353,7 @@ class TreeBehavior extends ModelBehavior {
|
||||||
public function generateTreeList(Model $Model, $conditions = null, $keyPath = null, $valuePath = null, $spacer = '_', $recursive = null) {
|
public function generateTreeList(Model $Model, $conditions = null, $keyPath = null, $valuePath = null, $spacer = '_', $recursive = null) {
|
||||||
$overrideRecursive = $recursive;
|
$overrideRecursive = $recursive;
|
||||||
extract($this->settings[$Model->alias]);
|
extract($this->settings[$Model->alias]);
|
||||||
if (!is_null($overrideRecursive)) {
|
if ($overrideRecursive !== null) {
|
||||||
$recursive = $overrideRecursive;
|
$recursive = $overrideRecursive;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -415,7 +415,7 @@ class TreeBehavior extends ModelBehavior {
|
||||||
$id = $Model->id;
|
$id = $Model->id;
|
||||||
}
|
}
|
||||||
extract($this->settings[$Model->alias]);
|
extract($this->settings[$Model->alias]);
|
||||||
if (!is_null($overrideRecursive)) {
|
if ($overrideRecursive !== null) {
|
||||||
$recursive = $overrideRecursive;
|
$recursive = $overrideRecursive;
|
||||||
}
|
}
|
||||||
$parentId = $Model->find('first', array('conditions' => array($Model->primaryKey => $id), 'fields' => array($parent), 'recursive' => -1));
|
$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;
|
$id = $Model->id;
|
||||||
}
|
}
|
||||||
extract($this->settings[$Model->alias]);
|
extract($this->settings[$Model->alias]);
|
||||||
if (!is_null($overrideRecursive)) {
|
if ($overrideRecursive !== null) {
|
||||||
$recursive = $overrideRecursive;
|
$recursive = $overrideRecursive;
|
||||||
}
|
}
|
||||||
$result = $Model->find('first', array('conditions' => array($Model->escapeField() => $id), 'fields' => array($left, $right), 'recursive' => $recursive));
|
$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) {
|
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],
|
$errors[] = array('node', $instance[$Model->alias][$Model->primaryKey],
|
||||||
'has invalid left or right values');
|
'has invalid left or right values');
|
||||||
} elseif ($instance[$Model->alias][$left] == $instance[$Model->alias][$right]) {
|
} elseif ($instance[$Model->alias][$left] == $instance[$Model->alias][$right]) {
|
||||||
|
|
|
@ -366,7 +366,7 @@ class CakeSession {
|
||||||
if (!self::start()) {
|
if (!self::start()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (is_null($name)) {
|
if ($name === null) {
|
||||||
return self::_returnSessionVars();
|
return self::_returnSessionVars();
|
||||||
}
|
}
|
||||||
if (empty($name)) {
|
if (empty($name)) {
|
||||||
|
|
|
@ -657,7 +657,7 @@ class Mysql extends DboSource {
|
||||||
* @return string Formatted length part of an index field
|
* @return string Formatted length part of an index field
|
||||||
*/
|
*/
|
||||||
protected function _buildIndexSubPart($lengths, $column) {
|
protected function _buildIndexSubPart($lengths, $column) {
|
||||||
if (is_null($lengths)) {
|
if ($lengths === null) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
if (!isset($lengths[$column])) {
|
if (!isset($lengths[$column])) {
|
||||||
|
|
|
@ -748,11 +748,11 @@ class Postgres extends DboSource {
|
||||||
|
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'bool':
|
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;
|
break;
|
||||||
case 'binary':
|
case 'binary':
|
||||||
case 'bytea':
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
$resultRow[$table][$column] = $row[$index];
|
$resultRow[$table][$column] = $row[$index];
|
||||||
|
|
|
@ -357,7 +357,7 @@ class Sqlite extends DboSource {
|
||||||
foreach ($this->map as $col => $meta) {
|
foreach ($this->map as $col => $meta) {
|
||||||
list($table, $column, $type) = $meta;
|
list($table, $column, $type) = $meta;
|
||||||
$resultRow[$table][$column] = $row[$col];
|
$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]);
|
$resultRow[$table][$column] = $this->boolean($resultRow[$table][$column]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -615,7 +615,7 @@ class Sqlserver extends DboSource {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$resultRow[$table][$column] = $row[$col];
|
$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]);
|
$resultRow[$table][$column] = $this->boolean($resultRow[$table][$column]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1035,7 +1035,7 @@ class DboSource extends DataSource {
|
||||||
$recursive = $queryData['recursive'];
|
$recursive = $queryData['recursive'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_null($recursive)) {
|
if ($recursive !== null) {
|
||||||
$_recursive = $model->recursive;
|
$_recursive = $model->recursive;
|
||||||
$model->recursive = $recursive;
|
$model->recursive = $recursive;
|
||||||
}
|
}
|
||||||
|
@ -1123,7 +1123,7 @@ class DboSource extends DataSource {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_null($recursive)) {
|
if ($recursive !== null) {
|
||||||
$model->recursive = $_recursive;
|
$model->recursive = $_recursive;
|
||||||
}
|
}
|
||||||
return $resultSet;
|
return $resultSet;
|
||||||
|
|
|
@ -2693,7 +2693,7 @@ class Model extends Object implements CakeEventListener {
|
||||||
$this->id = $this->getID();
|
$this->id = $this->getID();
|
||||||
|
|
||||||
$query = $this->buildQuery($type, $query);
|
$query = $this->buildQuery($type, $query);
|
||||||
if (is_null($query)) {
|
if ($query === null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -514,7 +514,7 @@ class CakeResponse {
|
||||||
*/
|
*/
|
||||||
protected function _sendHeader($name, $value = null) {
|
protected function _sendHeader($name, $value = null) {
|
||||||
if (!headers_sent()) {
|
if (!headers_sent()) {
|
||||||
if (is_null($value)) {
|
if ($value === null) {
|
||||||
header($name);
|
header($name);
|
||||||
} else {
|
} else {
|
||||||
header("{$name}: {$value}");
|
header("{$name}: {$value}");
|
||||||
|
@ -560,7 +560,7 @@ class CakeResponse {
|
||||||
* @return array list of headers to be sent
|
* @return array list of headers to be sent
|
||||||
*/
|
*/
|
||||||
public function header($header = null, $value = null) {
|
public function header($header = null, $value = null) {
|
||||||
if (is_null($header)) {
|
if ($header === null) {
|
||||||
return $this->_headers;
|
return $this->_headers;
|
||||||
}
|
}
|
||||||
if (is_array($header)) {
|
if (is_array($header)) {
|
||||||
|
@ -574,7 +574,7 @@ class CakeResponse {
|
||||||
return $this->_headers;
|
return $this->_headers;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_null($value)) {
|
if ($value !== null) {
|
||||||
$this->_headers[$header] = $value;
|
$this->_headers[$header] = $value;
|
||||||
return $this->_headers;
|
return $this->_headers;
|
||||||
}
|
}
|
||||||
|
@ -592,7 +592,7 @@ class CakeResponse {
|
||||||
* @return string current message buffer if $content param is passed as null
|
* @return string current message buffer if $content param is passed as null
|
||||||
*/
|
*/
|
||||||
public function body($content = null) {
|
public function body($content = null) {
|
||||||
if (is_null($content)) {
|
if ($content === null) {
|
||||||
return $this->_body;
|
return $this->_body;
|
||||||
}
|
}
|
||||||
return $this->_body = $content;
|
return $this->_body = $content;
|
||||||
|
@ -607,7 +607,7 @@ class CakeResponse {
|
||||||
* @throws CakeException When an unknown status code is reached.
|
* @throws CakeException When an unknown status code is reached.
|
||||||
*/
|
*/
|
||||||
public function statusCode($code = null) {
|
public function statusCode($code = null) {
|
||||||
if (is_null($code)) {
|
if ($code === null) {
|
||||||
return $this->_status;
|
return $this->_status;
|
||||||
}
|
}
|
||||||
if (!isset($this->_statusCodes[$code])) {
|
if (!isset($this->_statusCodes[$code])) {
|
||||||
|
@ -676,7 +676,7 @@ class CakeResponse {
|
||||||
* @return mixed current content type or false if supplied an invalid content type
|
* @return mixed current content type or false if supplied an invalid content type
|
||||||
*/
|
*/
|
||||||
public function type($contentType = null) {
|
public function type($contentType = null) {
|
||||||
if (is_null($contentType)) {
|
if ($contentType === null) {
|
||||||
return $this->_contentType;
|
return $this->_contentType;
|
||||||
}
|
}
|
||||||
if (is_array($contentType)) {
|
if (is_array($contentType)) {
|
||||||
|
@ -741,7 +741,7 @@ class CakeResponse {
|
||||||
* @return string current charset
|
* @return string current charset
|
||||||
*/
|
*/
|
||||||
public function charset($charset = null) {
|
public function charset($charset = null) {
|
||||||
if (is_null($charset)) {
|
if ($charset === null) {
|
||||||
return $this->_charset;
|
return $this->_charset;
|
||||||
}
|
}
|
||||||
return $this->_charset = $charset;
|
return $this->_charset = $charset;
|
||||||
|
@ -1248,7 +1248,7 @@ class CakeResponse {
|
||||||
|
|
||||||
$extension = strtolower($file->ext());
|
$extension = strtolower($file->ext());
|
||||||
$download = $options['download'];
|
$download = $options['download'];
|
||||||
if ((!$extension || $this->type($extension) === false) && is_null($download)) {
|
if ((!$extension || $this->type($extension) === false) && $download === null) {
|
||||||
$download = true;
|
$download = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1265,7 +1265,7 @@ class CakeResponse {
|
||||||
if (!empty($contentType)) {
|
if (!empty($contentType)) {
|
||||||
$this->type($contentType);
|
$this->type($contentType);
|
||||||
}
|
}
|
||||||
if (is_null($options['name'])) {
|
if ($options['name'] === null) {
|
||||||
$name = $file->name;
|
$name = $file->name;
|
||||||
} else {
|
} else {
|
||||||
$name = $options['name'];
|
$name = $options['name'];
|
||||||
|
|
|
@ -231,7 +231,7 @@ class SmtpTransport extends AbstractTransport {
|
||||||
* @throws SocketException
|
* @throws SocketException
|
||||||
*/
|
*/
|
||||||
protected function _smtpSend($data, $checkCode = '250') {
|
protected function _smtpSend($data, $checkCode = '250') {
|
||||||
if (!is_null($data)) {
|
if ($data !== null) {
|
||||||
$this->_socket->write($data . "\r\n");
|
$this->_socket->write($data . "\r\n");
|
||||||
}
|
}
|
||||||
while ($checkCode !== false) {
|
while ($checkCode !== false) {
|
||||||
|
|
|
@ -536,7 +536,7 @@ class HttpSocket extends CakeSocket {
|
||||||
* @return mixed Either false on failure or a string containing the composed URL.
|
* @return mixed Either false on failure or a string containing the composed URL.
|
||||||
*/
|
*/
|
||||||
public function url($url = null, $uriTemplate = null) {
|
public function url($url = null, $uriTemplate = null) {
|
||||||
if (is_null($url)) {
|
if ($url === null) {
|
||||||
$url = '/';
|
$url = '/';
|
||||||
}
|
}
|
||||||
if (is_string($url)) {
|
if (is_string($url)) {
|
||||||
|
|
|
@ -138,7 +138,7 @@ class HttpSocketResponse implements ArrayAccess {
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function isRedirect() {
|
public function isRedirect() {
|
||||||
return in_array($this->code, array(301, 302, 303, 307)) && !is_null($this->getHeader('Location'));
|
return in_array($this->code, array(301, 302, 303, 307)) && $this->getHeader('Location') !== null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -175,7 +175,7 @@ class Router {
|
||||||
* @throws RouterException
|
* @throws RouterException
|
||||||
*/
|
*/
|
||||||
public static function defaultRouteClass($routeClass = null) {
|
public static function defaultRouteClass($routeClass = null) {
|
||||||
if (is_null($routeClass)) {
|
if ($routeClass === null) {
|
||||||
return self::$_routeClass;
|
return self::$_routeClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -588,7 +588,7 @@ class ModelValidationTest extends BaseModelTest {
|
||||||
$this->assertFalse($result, 'Save occurred even when with models failed. %s');
|
$this->assertFalse($result, 'Save occurred even when with models failed. %s');
|
||||||
$this->assertEquals($expectedError, $JoinThing->validationErrors);
|
$this->assertEquals($expectedError, $JoinThing->validationErrors);
|
||||||
$count = $Something->find('count', array('conditions' => array('Something.id' => $data['Something']['id'])));
|
$count = $Something->find('count', array('conditions' => array('Something.id' => $data['Something']['id'])));
|
||||||
$this->assertSame($count, 0);
|
$this->assertSame(0, $count);
|
||||||
|
|
||||||
$data = array(
|
$data = array(
|
||||||
'Something' => array(
|
'Something' => array(
|
||||||
|
@ -651,7 +651,7 @@ class ModelValidationTest extends BaseModelTest {
|
||||||
$this->assertEquals($expectedError, $JoinThing->validationErrors);
|
$this->assertEquals($expectedError, $JoinThing->validationErrors);
|
||||||
|
|
||||||
$count = $Something->find('count', array('conditions' => array('Something.id' => $data['Something']['id'])));
|
$count = $Something->find('count', array('conditions' => array('Something.id' => $data['Something']['id'])));
|
||||||
$this->assertSame($count, 0);
|
$this->assertSame(0, $count);
|
||||||
|
|
||||||
$joinRecords = $JoinThing->find('count', array(
|
$joinRecords = $JoinThing->find('count', array(
|
||||||
'conditions' => array('JoinThing.something_id' => $data['Something']['id'])
|
'conditions' => array('JoinThing.something_id' => $data['Something']['id'])
|
||||||
|
@ -692,11 +692,11 @@ class ModelValidationTest extends BaseModelTest {
|
||||||
$Author->create();
|
$Author->create();
|
||||||
$result = $Author->saveAll($data, array('validate' => 'first'));
|
$result = $Author->saveAll($data, array('validate' => 'first'));
|
||||||
$this->assertTrue($result);
|
$this->assertTrue($result);
|
||||||
$this->assertFalse(is_null($Author->id));
|
$this->assertNotNull($Author->id);
|
||||||
|
|
||||||
$id = $Author->id;
|
$id = $Author->id;
|
||||||
$count = $Author->find('count', array('conditions' => array('Author.id' => $id)));
|
$count = $Author->find('count', array('conditions' => array('Author.id' => $id)));
|
||||||
$this->assertSame($count, 1);
|
$this->assertSame(1, $count);
|
||||||
|
|
||||||
$count = $Post->find('count', array(
|
$count = $Post->find('count', array(
|
||||||
'conditions' => array('Post.author_id' => $id)
|
'conditions' => array('Post.author_id' => $id)
|
||||||
|
@ -2315,7 +2315,7 @@ class ModelValidationTest extends BaseModelTest {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
$this->assertEquals($result, $expected);
|
$this->assertEquals($expected, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2376,7 +2376,7 @@ class ModelValidationTest extends BaseModelTest {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
$this->assertEquals($result, $expected);
|
$this->assertEquals($expected, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -217,19 +217,19 @@ class FileTest extends CakeTestCase {
|
||||||
$this->assertTrue(is_resource($this->File->handle));
|
$this->assertTrue(is_resource($this->File->handle));
|
||||||
|
|
||||||
$result = $this->File->offset();
|
$result = $this->File->offset();
|
||||||
$expecting = 0;
|
$expected = 0;
|
||||||
$this->assertSame($result, $expecting);
|
$this->assertSame($expected, $result);
|
||||||
|
|
||||||
$data = file_get_contents(__FILE__);
|
$data = file_get_contents(__FILE__);
|
||||||
$success = $this->File->offset(5);
|
$success = $this->File->offset(5);
|
||||||
$expecting = substr($data, 5, 3);
|
$expected = substr($data, 5, 3);
|
||||||
$result = $this->File->read(3);
|
$result = $this->File->read(3);
|
||||||
$this->assertTrue($success);
|
$this->assertTrue($success);
|
||||||
$this->assertEquals($expecting, $result);
|
$this->assertEquals($expected, $result);
|
||||||
|
|
||||||
$result = $this->File->offset();
|
$result = $this->File->offset();
|
||||||
$expecting = 5 + 3;
|
$expected = 5 + 3;
|
||||||
$this->assertSame($result, $expecting);
|
$this->assertSame($expected, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2209,7 +2209,7 @@ class HashTest extends CakeTestCase {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$this->assertEquals($result, $expected);
|
$this->assertEquals($expected, $result);
|
||||||
|
|
||||||
$data = array('a.b.100.a' => null, 'a.b.200.a' => null);
|
$data = array('a.b.100.a' => null, 'a.b.200.a' => null);
|
||||||
$expected = array(
|
$expected = array(
|
||||||
|
|
|
@ -693,7 +693,7 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase {
|
||||||
* @return Model
|
* @return Model
|
||||||
*/
|
*/
|
||||||
public function getMockForModel($model, $methods = array(), $config = null) {
|
public function getMockForModel($model, $methods = array(), $config = null) {
|
||||||
if (is_null($config)) {
|
if ($config === null) {
|
||||||
$config = ClassRegistry::config('Model');
|
$config = ClassRegistry::config('Model');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -248,7 +248,7 @@ class CakeTime {
|
||||||
*/
|
*/
|
||||||
public static function convert($serverTime, $timezone) {
|
public static function convert($serverTime, $timezone) {
|
||||||
static $serverTimezone = null;
|
static $serverTimezone = null;
|
||||||
if (is_null($serverTimezone) || (date_default_timezone_get() !== $serverTimezone->getName())) {
|
if ($serverTimezone === null || (date_default_timezone_get() !== $serverTimezone->getName())) {
|
||||||
$serverTimezone = new DateTimeZone(date_default_timezone_get());
|
$serverTimezone = new DateTimeZone(date_default_timezone_get());
|
||||||
}
|
}
|
||||||
$serverOffset = $serverTimezone->getOffset(new DateTime('@' . $serverTime));
|
$serverOffset = $serverTimezone->getOffset(new DateTime('@' . $serverTime));
|
||||||
|
@ -647,7 +647,7 @@ class CakeTime {
|
||||||
public static function toRSS($dateString, $timezone = null) {
|
public static function toRSS($dateString, $timezone = null) {
|
||||||
$date = self::fromString($dateString, $timezone);
|
$date = self::fromString($dateString, $timezone);
|
||||||
|
|
||||||
if (is_null($timezone)) {
|
if ($timezone === null) {
|
||||||
return date("r", $date);
|
return date("r", $date);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -289,7 +289,7 @@ class ClassRegistry {
|
||||||
if (empty($param) && is_array($type)) {
|
if (empty($param) && is_array($type)) {
|
||||||
$param = $type;
|
$param = $type;
|
||||||
$type = 'Model';
|
$type = 'Model';
|
||||||
} elseif (is_null($param)) {
|
} elseif ($param === null) {
|
||||||
unset($_this->_config[$type]);
|
unset($_this->_config[$type]);
|
||||||
} elseif (empty($param) && is_string($type)) {
|
} elseif (empty($param) && is_string($type)) {
|
||||||
return isset($_this->_config[$type]) ? $_this->_config[$type] : null;
|
return isset($_this->_config[$type]) ? $_this->_config[$type] : null;
|
||||||
|
|
|
@ -706,7 +706,7 @@ class Debugger {
|
||||||
$self = Debugger::getInstance();
|
$self = Debugger::getInstance();
|
||||||
$data = null;
|
$data = null;
|
||||||
|
|
||||||
if (is_null($format)) {
|
if ($format === null) {
|
||||||
return Debugger::outputAs();
|
return Debugger::outputAs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -815,7 +815,7 @@ class Debugger {
|
||||||
if (is_object($var)) {
|
if (is_object($var)) {
|
||||||
return get_class($var);
|
return get_class($var);
|
||||||
}
|
}
|
||||||
if (is_null($var)) {
|
if ($var === null) {
|
||||||
return 'null';
|
return 'null';
|
||||||
}
|
}
|
||||||
if (is_string($var)) {
|
if (is_string($var)) {
|
||||||
|
|
|
@ -395,7 +395,7 @@ class File {
|
||||||
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::pwd
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::pwd
|
||||||
*/
|
*/
|
||||||
public function pwd() {
|
public function pwd() {
|
||||||
if (is_null($this->path)) {
|
if ($this->path === null) {
|
||||||
$this->path = $this->Folder->slashTerm($this->Folder->pwd()) . $this->name;
|
$this->path = $this->Folder->slashTerm($this->Folder->pwd()) . $this->name;
|
||||||
}
|
}
|
||||||
return $this->path;
|
return $this->path;
|
||||||
|
|
|
@ -816,7 +816,7 @@ class Hash {
|
||||||
$stack = array();
|
$stack = array();
|
||||||
foreach ($data as $k => $r) {
|
foreach ($data as $k => $r) {
|
||||||
$id = $k;
|
$id = $k;
|
||||||
if (!is_null($key)) {
|
if ($key !== null) {
|
||||||
$id = $key;
|
$id = $key;
|
||||||
}
|
}
|
||||||
if (is_array($r) && !empty($r)) {
|
if (is_array($r) && !empty($r)) {
|
||||||
|
|
|
@ -225,7 +225,7 @@ abstract class ObjectCollection {
|
||||||
}
|
}
|
||||||
foreach ($name as $object => $objectPriority) {
|
foreach ($name as $object => $objectPriority) {
|
||||||
if (isset($this->_loaded[$object])) {
|
if (isset($this->_loaded[$object])) {
|
||||||
if (is_null($objectPriority)) {
|
if ($objectPriority === null) {
|
||||||
$objectPriority = $this->defaultPriority;
|
$objectPriority = $this->defaultPriority;
|
||||||
}
|
}
|
||||||
$this->_loaded[$object]->settings['priority'] = $objectPriority;
|
$this->_loaded[$object]->settings['priority'] = $objectPriority;
|
||||||
|
|
|
@ -935,7 +935,7 @@ class Set {
|
||||||
$stack = array();
|
$stack = array();
|
||||||
foreach ($results as $k => $r) {
|
foreach ($results as $k => $r) {
|
||||||
$id = $k;
|
$id = $k;
|
||||||
if (!is_null($key)) {
|
if ($key !== null) {
|
||||||
$id = $key;
|
$id = $key;
|
||||||
}
|
}
|
||||||
if (is_array($r) && !empty($r)) {
|
if (is_array($r) && !empty($r)) {
|
||||||
|
|
|
@ -149,7 +149,7 @@ class Validation {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_null($regex)) {
|
if ($regex !== null) {
|
||||||
if (self::_check($check, $regex)) {
|
if (self::_check($check, $regex)) {
|
||||||
return self::luhn($check, $deep);
|
return self::luhn($check, $deep);
|
||||||
}
|
}
|
||||||
|
@ -295,7 +295,7 @@ class Validation {
|
||||||
* @return boolean Success
|
* @return boolean Success
|
||||||
*/
|
*/
|
||||||
public static function date($check, $format = 'ymd', $regex = null) {
|
public static function date($check, $format = 'ymd', $regex = null) {
|
||||||
if (!is_null($regex)) {
|
if ($regex !== null) {
|
||||||
return self::_check($check, $regex);
|
return self::_check($check, $regex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -386,7 +386,7 @@ class Validation {
|
||||||
* @return boolean Success
|
* @return boolean Success
|
||||||
*/
|
*/
|
||||||
public static function decimal($check, $places = null, $regex = null) {
|
public static function decimal($check, $places = null, $regex = null) {
|
||||||
if (is_null($regex)) {
|
if ($regex === null) {
|
||||||
$lnum = '[0-9]+';
|
$lnum = '[0-9]+';
|
||||||
$dnum = "[0-9]*[\.]{$lnum}";
|
$dnum = "[0-9]*[\.]{$lnum}";
|
||||||
$sign = '[+-]?';
|
$sign = '[+-]?';
|
||||||
|
@ -426,7 +426,7 @@ class Validation {
|
||||||
extract(self::_defaults($check));
|
extract(self::_defaults($check));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_null($regex)) {
|
if ($regex === null) {
|
||||||
$regex = '/^[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+)*@' . self::$_pattern['hostname'] . '$/i';
|
$regex = '/^[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+)*@' . self::$_pattern['hostname'] . '$/i';
|
||||||
}
|
}
|
||||||
$return = self::_check($check, $regex);
|
$return = self::_check($check, $regex);
|
||||||
|
@ -608,7 +608,7 @@ class Validation {
|
||||||
extract(self::_defaults($check));
|
extract(self::_defaults($check));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_null($regex)) {
|
if ($regex === null) {
|
||||||
switch ($country) {
|
switch ($country) {
|
||||||
case 'us':
|
case 'us':
|
||||||
case 'all':
|
case 'all':
|
||||||
|
@ -638,7 +638,7 @@ class Validation {
|
||||||
extract(self::_defaults($check));
|
extract(self::_defaults($check));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_null($regex)) {
|
if ($regex === null) {
|
||||||
switch ($country) {
|
switch ($country) {
|
||||||
case 'uk':
|
case 'uk':
|
||||||
$regex = '/\\A\\b[A-Z]{1,2}[0-9][A-Z0-9]? [0-9][ABD-HJLNP-UW-Z]{2}\\b\\z/i';
|
$regex = '/\\A\\b[A-Z]{1,2}[0-9][A-Z0-9]? [0-9][ABD-HJLNP-UW-Z]{2}\\b\\z/i';
|
||||||
|
@ -699,7 +699,7 @@ class Validation {
|
||||||
extract(self::_defaults($check));
|
extract(self::_defaults($check));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_null($regex)) {
|
if ($regex === null) {
|
||||||
switch ($country) {
|
switch ($country) {
|
||||||
case 'dk':
|
case 'dk':
|
||||||
$regex = '/\\A\\b[0-9]{6}-[0-9]{4}\\b\\z/i';
|
$regex = '/\\A\\b[0-9]{6}-[0-9]{4}\\b\\z/i';
|
||||||
|
|
|
@ -310,7 +310,7 @@ class Xml {
|
||||||
}
|
}
|
||||||
|
|
||||||
$child = $dom->createElement($key);
|
$child = $dom->createElement($key);
|
||||||
if (!is_null($childValue)) {
|
if ($childValue !== null) {
|
||||||
$child->appendChild($dom->createTextNode($childValue));
|
$child->appendChild($dom->createTextNode($childValue));
|
||||||
}
|
}
|
||||||
if ($childNS) {
|
if ($childNS) {
|
||||||
|
|
|
@ -2864,7 +2864,7 @@ class FormHelper extends AppHelper {
|
||||||
* @return array inputDefaults
|
* @return array inputDefaults
|
||||||
*/
|
*/
|
||||||
public function inputDefaults($defaults = null, $merge = false) {
|
public function inputDefaults($defaults = null, $merge = false) {
|
||||||
if (!is_null($defaults)) {
|
if ($defaults !== null) {
|
||||||
if ($merge) {
|
if ($merge) {
|
||||||
$this->_inputDefaults = array_merge($this->_inputDefaults, (array)$defaults);
|
$this->_inputDefaults = array_merge($this->_inputDefaults, (array)$defaults);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -260,7 +260,7 @@ class RssHelper extends AppHelper {
|
||||||
default:
|
default:
|
||||||
$attrib = $att;
|
$attrib = $att;
|
||||||
}
|
}
|
||||||
if (!is_null($val) && $escape) {
|
if ($val !== null && $escape) {
|
||||||
$val = h($val);
|
$val = h($val);
|
||||||
}
|
}
|
||||||
$elements[$key] = $this->elem($key, $attrib, $val);
|
$elements[$key] = $this->elem($key, $attrib, $val);
|
||||||
|
|
|
@ -58,7 +58,7 @@ class ScaffoldView extends View {
|
||||||
|
|
||||||
$scaffoldAction = 'scaffold.' . $name;
|
$scaffoldAction = 'scaffold.' . $name;
|
||||||
|
|
||||||
if (!is_null($this->subDir)) {
|
if ($this->subDir !== null) {
|
||||||
$subDir = strtolower($this->subDir) . DS;
|
$subDir = strtolower($this->subDir) . DS;
|
||||||
} else {
|
} else {
|
||||||
$subDir = null;
|
$subDir = null;
|
||||||
|
|
|
@ -972,7 +972,7 @@ class View extends Object {
|
||||||
protected function _getViewFileName($name = null) {
|
protected function _getViewFileName($name = null) {
|
||||||
$subDir = null;
|
$subDir = null;
|
||||||
|
|
||||||
if (!is_null($this->subDir)) {
|
if ($this->subDir !== null) {
|
||||||
$subDir = $this->subDir . DS;
|
$subDir = $this->subDir . DS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1054,7 +1054,7 @@ class View extends Object {
|
||||||
}
|
}
|
||||||
$subDir = null;
|
$subDir = null;
|
||||||
|
|
||||||
if (!is_null($this->layoutPath)) {
|
if ($this->layoutPath !== null) {
|
||||||
$subDir = $this->layoutPath . DS;
|
$subDir = $this->layoutPath . DS;
|
||||||
}
|
}
|
||||||
list($plugin, $name) = $this->pluginSplit($name);
|
list($plugin, $name) = $this->pluginSplit($name);
|
||||||
|
|
Loading…
Reference in a new issue