Merge branch 'master' into 2.4

Conflicts:
	lib/Cake/Network/CakeResponse.php
	lib/Cake/TestSuite/CakeTestCase.php
This commit is contained in:
mark_story 2013-08-18 23:10:08 -04:00
commit 0f2d59d987
41 changed files with 133 additions and 83 deletions

View file

@ -407,7 +407,7 @@ class ControllerTask extends BakeTask {
* @return array Set of controllers
*/
public function listAll($useDbConfig = null) {
if (is_null($useDbConfig)) {
if ($useDbConfig === null) {
$useDbConfig = $this->connection;
}
$this->__tables = $this->Model->getAllTables($useDbConfig);

View file

@ -243,7 +243,7 @@ class FixtureTask extends BakeTask {
}
$tableInfo = $data['tables'][$useTable];
if (is_null($modelImport)) {
if ($modelImport === null) {
$schema = $this->_generateSchema($tableInfo);
}

View file

@ -179,8 +179,6 @@ if (!empty($associations['hasAndBelongsToMany'])):
$out .= "\t\t\t'limit' => '',\n";
$out .= "\t\t\t'offset' => '',\n";
$out .= "\t\t\t'finderQuery' => '',\n";
$out .= "\t\t\t'deleteQuery' => '',\n";
$out .= "\t\t\t'insertQuery' => ''\n";
$out .= "\t\t)";
if ($i + 1 < $habtmCount) {
$out .= ",";

View file

@ -717,7 +717,7 @@ class AuthComponent extends Component {
* @return string Redirect URL
*/
public function redirectUrl($url = null) {
if (!is_null($url)) {
if ($url !== null) {
$redir = $url;
$this->Session->write('Auth.redirect', $redir);
} elseif ($this->Session->check('Auth.redirect')) {

View file

@ -219,7 +219,7 @@ class CookieComponent extends Component {
$this->read();
}
if (is_null($encrypt)) {
if ($encrypt === null) {
$encrypt = true;
}
$this->_encrypted = $encrypt;
@ -262,7 +262,7 @@ class CookieComponent extends Component {
if (empty($this->_values[$this->name])) {
$this->_values[$this->name] = array();
}
if (is_null($key)) {
if ($key === null) {
return $this->_values[$this->name];
}
@ -387,7 +387,7 @@ class CookieComponent extends Component {
* @return integer Unix timestamp
*/
protected function _expire($expires = null) {
if (is_null($expires)) {
if ($expires === null) {
return $this->_expires;
}
$this->_reset = $this->_expires;

View file

@ -228,7 +228,7 @@ class CakePlugin {
* @return void
*/
public static function unload($plugin = null) {
if (is_null($plugin)) {
if ($plugin === null) {
self::$_plugins = array();
} else {
unset(self::$_plugins[$plugin]);

View file

@ -161,7 +161,7 @@ class I18n {
$_this->_lang = $lang;
}
if (is_null($domain)) {
if ($domain === null) {
$domain = self::$defaultDomain;
}
if ($domain === '') {

View file

@ -269,7 +269,7 @@ class ContainableBehavior extends ModelBehavior {
* @return array Containments
*/
public function containments(Model $Model, $contain, $containments = array(), $throwErrors = null) {
$options = array('className', 'joinTable', 'with', 'foreignKey', 'associationForeignKey', 'conditions', 'fields', 'order', 'limit', 'offset', 'unique', 'finderQuery', 'deleteQuery', 'insertQuery');
$options = array('className', 'joinTable', 'with', 'foreignKey', 'associationForeignKey', 'conditions', 'fields', 'order', 'limit', 'offset', 'unique', 'finderQuery');
$keep = array();
if ($throwErrors === null) {
$throwErrors = (empty($this->settings[$Model->alias]) ? true : $this->settings[$Model->alias]['notices']);

View file

@ -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;
}
}

View file

@ -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));
@ -876,7 +876,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]) {

View file

@ -366,7 +366,7 @@ class CakeSession {
if (!self::start()) {
return false;
}
if (is_null($name)) {
if ($name === null) {
return self::_returnSessionVars();
}
if (empty($name)) {

View file

@ -677,7 +677,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])) {

View file

@ -753,11 +753,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];

View file

@ -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]);
}
}

View file

@ -620,7 +620,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]);
}
}

View file

@ -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;

View file

@ -464,8 +464,8 @@ class Model extends Object implements CakeEventListener {
* - `limit`: The maximum number of associated rows you want returned.
* - `offset`: The number of associated rows to skip over (given the current
* conditions and order) before fetching and associating.
* - `finderQuery`, `deleteQuery`, `insertQuery`: A complete SQL query CakePHP
* can use to fetch, delete, or create new associated model records. This should
* - `finderQuery`, A complete SQL query CakePHP
* can use to fetch associated model records. This should
* be used in situations that require very custom results.
*
* @var array
@ -555,7 +555,7 @@ class Model extends Object implements CakeEventListener {
'belongsTo' => array('className', 'foreignKey', 'conditions', 'fields', 'order', 'counterCache'),
'hasOne' => array('className', 'foreignKey', 'conditions', 'fields', 'order', 'dependent'),
'hasMany' => array('className', 'foreignKey', 'conditions', 'fields', 'order', 'limit', 'offset', 'dependent', 'exclusive', 'finderQuery', 'counterQuery'),
'hasAndBelongsToMany' => array('className', 'joinTable', 'with', 'foreignKey', 'associationForeignKey', 'conditions', 'fields', 'order', 'limit', 'offset', 'unique', 'finderQuery', 'deleteQuery', 'insertQuery')
'hasAndBelongsToMany' => array('className', 'joinTable', 'with', 'foreignKey', 'associationForeignKey', 'conditions', 'fields', 'order', 'limit', 'offset', 'unique', 'finderQuery')
);
/**
@ -2715,7 +2715,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;
}

View file

@ -516,7 +516,7 @@ class CakeResponse {
*/
protected function _sendHeader($name, $value = null) {
if (!headers_sent()) {
if (is_null($value)) {
if ($value === null) {
header($name);
} else {
header("{$name}: {$value}");
@ -562,7 +562,7 @@ class CakeResponse {
* @return array list of headers to be sent
*/
public function header($header = null, $value = null) {
if (is_null($header)) {
if ($header === null) {
return $this->_headers;
}
$headers = is_array($header) ? $header : array($header => $value);
@ -602,7 +602,7 @@ class CakeResponse {
* @return string current message buffer if $content param is passed as null
*/
public function body($content = null) {
if (is_null($content)) {
if ($content === null) {
return $this->_body;
}
return $this->_body = $content;
@ -617,7 +617,7 @@ class CakeResponse {
* @throws CakeException When an unknown status code is reached.
*/
public function statusCode($code = null) {
if (is_null($code)) {
if ($code === null) {
return $this->_status;
}
if (!isset($this->_statusCodes[$code])) {
@ -702,7 +702,7 @@ class CakeResponse {
* @return mixed current content type or false if supplied an invalid content type
*/
public function type($contentType = null) {
if (is_null($contentType)) {
if ($contentType === null) {
return $this->_contentType;
}
if (is_array($contentType)) {
@ -765,7 +765,7 @@ class CakeResponse {
* @return string current charset
*/
public function charset($charset = null) {
if (is_null($charset)) {
if ($charset === null) {
return $this->_charset;
}
return $this->_charset = $charset;
@ -1272,7 +1272,7 @@ class CakeResponse {
$extension = strtolower($file->ext());
$download = $options['download'];
if ((!$extension || $this->type($extension) === false) && is_null($download)) {
if ((!$extension || $this->type($extension) === false) && $download === null) {
$download = true;
}
@ -1289,7 +1289,7 @@ class CakeResponse {
if (!empty($contentType)) {
$this->type($contentType);
}
if (is_null($options['name'])) {
if ($options['name'] === null) {
$name = $file->name;
} else {
$name = $options['name'];

View file

@ -231,7 +231,7 @@ class SmtpTransport extends AbstractTransport {
* @throws SocketException
*/
protected function _smtpSend($data, $checkCode = '250') {
if (!is_null($data)) {
if ($data !== null) {
$this->_socket->write($data . "\r\n");
}
while ($checkCode !== false) {

View file

@ -550,7 +550,7 @@ class HttpSocket extends CakeSocket {
* @return mixed Either false on failure or a string containing the composed URL.
*/
public function url($url = null, $uriTemplate = null) {
if (is_null($url)) {
if ($url === null) {
$url = '/';
}
if (is_string($url)) {

View file

@ -138,7 +138,7 @@ class HttpSocketResponse implements ArrayAccess {
* @return boolean
*/
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;
}
/**

View file

@ -80,6 +80,13 @@ class RedirectRoute extends CakeRoute {
}
if (isset($this->options['persist']) && is_array($redirect)) {
$redirect += array('named' => $params['named'], 'pass' => $params['pass'], 'url' => array());
if (is_array($this->options['persist'])) {
foreach ($this->options['persist'] as $elem) {
if (isset($params[$elem])) {
$redirect[$elem] = $params[$elem];
}
}
}
$redirect = Router::reverse($redirect);
}
$status = 301;

View file

@ -183,7 +183,7 @@ class Router {
* @throws RouterException
*/
public static function defaultRouteClass($routeClass = null) {
if (is_null($routeClass)) {
if ($routeClass === null) {
return self::$_routeClass;
}

View file

@ -1491,7 +1491,7 @@ class ModelIntegrationTest extends BaseModelTest {
'dynamicWith' => true,
'associationForeignKey' => 'join_b_id',
'conditions' => '', 'fields' => '', 'order' => '', 'limit' => '', 'offset' => '',
'finderQuery' => '', 'deleteQuery' => '', 'insertQuery' => ''
'finderQuery' => ''
));
$this->assertEquals($expected, $result);
@ -1568,8 +1568,6 @@ class ModelIntegrationTest extends BaseModelTest {
'offset' => '',
'unique' => true,
'finderQuery' => '',
'deleteQuery' => '',
'insertQuery' => ''
));
$this->assertSame($TestModel->hasAndBelongsToMany, $expected);

View file

@ -588,7 +588,7 @@ class ModelValidationTest extends BaseModelTest {
$this->assertFalse($result, 'Save occurred even when with models failed. %s');
$this->assertEquals($expectedError, $JoinThing->validationErrors);
$count = $Something->find('count', array('conditions' => array('Something.id' => $data['Something']['id'])));
$this->assertSame($count, 0);
$this->assertSame(0, $count);
$data = array(
'Something' => array(
@ -651,7 +651,7 @@ class ModelValidationTest extends BaseModelTest {
$this->assertEquals($expectedError, $JoinThing->validationErrors);
$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(
'conditions' => array('JoinThing.something_id' => $data['Something']['id'])
@ -692,11 +692,11 @@ class ModelValidationTest extends BaseModelTest {
$Author->create();
$result = $Author->saveAll($data, array('validate' => 'first'));
$this->assertTrue($result);
$this->assertFalse(is_null($Author->id));
$this->assertNotNull($Author->id);
$id = $Author->id;
$count = $Author->find('count', array('conditions' => array('Author.id' => $id)));
$this->assertSame($count, 1);
$this->assertSame(1, $count);
$count = $Post->find('count', array(
'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);
}
}

View file

@ -103,6 +103,22 @@ class RedirectRouteTest extends CakeTestCase {
$result = $route->parse('/my_controllers/do_something/passme/named:param');
$header = $route->response->header();
$this->assertEquals(Router::url('/tags/add', true), $header['Location']);
$route = new RedirectRoute('/:lang/my_controllers', array('controller' => 'tags', 'action' => 'add'), array('lang' => '(nl|en)', 'persist' => array('lang')));
$route->stop = false;
$route->response = $this->getMock('CakeResponse', array('_sendHeader'));
$result = $route->parse('/nl/my_controllers/');
$header = $route->response->header();
$this->assertEquals(Router::url('/tags/add/lang:nl', true), $header['Location']);
Router::$routes = array(); // reset default routes
Router::connect('/:lang/preferred_controllers', array('controller' => 'tags', 'action' => 'add'), array('lang' => '(nl|en)', 'persist' => array('lang')));
$route = new RedirectRoute('/:lang/my_controllers', array('controller' => 'tags', 'action' => 'add'), array('lang' => '(nl|en)', 'persist' => array('lang')));
$route->stop = false;
$route->response = $this->getMock('CakeResponse', array('_sendHeader'));
$result = $route->parse('/nl/my_controllers/');
$header = $route->response->header();
$this->assertEquals(Router::url('/nl/preferred_controllers', true), $header['Location']);
}
}

View file

@ -217,19 +217,19 @@ class FileTest extends CakeTestCase {
$this->assertTrue(is_resource($this->File->handle));
$result = $this->File->offset();
$expecting = 0;
$this->assertSame($result, $expecting);
$expected = 0;
$this->assertSame($expected, $result);
$data = file_get_contents(__FILE__);
$success = $this->File->offset(5);
$expecting = substr($data, 5, 3);
$expected = substr($data, 5, 3);
$result = $this->File->read(3);
$this->assertTrue($success);
$this->assertEquals($expecting, $result);
$this->assertEquals($expected, $result);
$result = $this->File->offset();
$expecting = 5 + 3;
$this->assertSame($result, $expecting);
$expected = 5 + 3;
$this->assertSame($expected, $result);
}
/**

View file

@ -1042,7 +1042,7 @@ class HashTest extends CakeTestCase {
1 => array('Person' => array('name' => 'Jeff')),
);
$a = Hash::sort($a, '{n}.Person.name', 'ASC', 'STRING');
$this->assertEquals($a, $b);
$this->assertSame($a, $b);
$names = array(
array('employees' => array(
@ -1065,7 +1065,38 @@ class HashTest extends CakeTestCase {
array('employees' => array(array('name' => array()))),
array('employees' => array(array('name' => array())))
);
$this->assertEquals($expected, $result);
$this->assertSame($expected, $result);
$a = array(
'SU' => array(
'total_fulfillable' => 2
),
'AA' => array(
'total_fulfillable' => 1
),
'LX' => array(
'total_fulfillable' => 0
),
'BL' => array(
'total_fulfillable' => 3
),
);
$expected = array(
'LX' => array(
'total_fulfillable' => 0
),
'AA' => array(
'total_fulfillable' => 1
),
'SU' => array(
'total_fulfillable' => 2
),
'BL' => array(
'total_fulfillable' => 3
),
);
$result = Hash::sort($a, '{s}.total_fulfillable', 'asc');
$this->assertSame($expected, $result);
}
/**
@ -2209,7 +2240,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);
$expected = array(

View file

@ -248,7 +248,7 @@ class CakeTime {
*/
public static function convert($serverTime, $timezone) {
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());
}
$serverOffset = $serverTimezone->getOffset(new DateTime('@' . $serverTime));
@ -673,7 +673,7 @@ class CakeTime {
public static function toRSS($dateString, $timezone = null) {
$date = self::fromString($dateString, $timezone);
if (is_null($timezone)) {
if ($timezone === null) {
return date("r", $date);
}

View file

@ -289,7 +289,7 @@ class ClassRegistry {
if (empty($param) && is_array($type)) {
$param = $type;
$type = 'Model';
} elseif (is_null($param)) {
} elseif ($param === null) {
unset($_this->_config[$type]);
} elseif (empty($param) && is_string($type)) {
return isset($_this->_config[$type]) ? $_this->_config[$type] : null;

View file

@ -706,7 +706,7 @@ class Debugger {
$self = Debugger::getInstance();
$data = null;
if (is_null($format)) {
if ($format === null) {
return Debugger::outputAs();
}
@ -815,7 +815,7 @@ class Debugger {
if (is_object($var)) {
return get_class($var);
}
if (is_null($var)) {
if ($var === null) {
return 'null';
}
if (is_string($var)) {

View file

@ -395,7 +395,7 @@ class File {
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::pwd
*/
public function pwd() {
if (is_null($this->path)) {
if ($this->path === null) {
$this->path = $this->Folder->slashTerm($this->Folder->pwd()) . $this->name;
}
return $this->path;

View file

@ -816,7 +816,7 @@ class Hash {
$stack = array();
foreach ($data as $k => $r) {
$id = $k;
if (!is_null($key)) {
if ($key !== null) {
$id = $key;
}
if (is_array($r) && !empty($r)) {

View file

@ -225,7 +225,7 @@ abstract class ObjectCollection {
}
foreach ($name as $object => $objectPriority) {
if (isset($this->_loaded[$object])) {
if (is_null($objectPriority)) {
if ($objectPriority === null) {
$objectPriority = $this->defaultPriority;
}
$this->_loaded[$object]->settings['priority'] = $objectPriority;

View file

@ -935,7 +935,7 @@ class Set {
$stack = array();
foreach ($results as $k => $r) {
$id = $k;
if (!is_null($key)) {
if ($key !== null) {
$id = $key;
}
if (is_array($r) && !empty($r)) {

View file

@ -149,7 +149,7 @@ class Validation {
return false;
}
if (!is_null($regex)) {
if ($regex !== null) {
if (self::_check($check, $regex)) {
return self::luhn($check, $deep);
}
@ -297,7 +297,7 @@ class Validation {
* @return boolean Success
*/
public static function date($check, $format = 'ymd', $regex = null) {
if (!is_null($regex)) {
if ($regex !== null) {
return self::_check($check, $regex);
}
@ -390,7 +390,7 @@ class Validation {
* @return boolean Success
*/
public static function decimal($check, $places = null, $regex = null) {
if (is_null($regex)) {
if ($regex === null) {
$lnum = '[0-9]+';
$dnum = "[0-9]*[\.]{$lnum}";
$sign = '[+-]?';
@ -430,7 +430,7 @@ class Validation {
extract(self::_defaults($check));
}
if (is_null($regex)) {
if ($regex === null) {
$regex = '/^[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+)*@' . self::$_pattern['hostname'] . '$/i';
}
$return = self::_check($check, $regex);
@ -612,7 +612,7 @@ class Validation {
extract(self::_defaults($check));
}
if (is_null($regex)) {
if ($regex === null) {
switch ($country) {
case 'us':
case 'ca':
@ -649,7 +649,7 @@ class Validation {
extract(self::_defaults($check));
}
if (is_null($regex)) {
if ($regex === null) {
switch ($country) {
case 'uk':
$regex = '/\\A\\b[A-Z]{1,2}[0-9][A-Z0-9]? [0-9][ABD-HJLNP-UW-Z]{2}\\b\\z/i';
@ -710,7 +710,7 @@ class Validation {
extract(self::_defaults($check));
}
if (is_null($regex)) {
if ($regex === null) {
switch ($country) {
case 'dk':
$regex = '/\\A\\b[0-9]{6}-[0-9]{4}\\b\\z/i';

View file

@ -315,7 +315,7 @@ class Xml {
}
$child = $dom->createElement($key);
if (!is_null($childValue)) {
if ($childValue !== null) {
$child->appendChild($dom->createTextNode($childValue));
}
if ($childNS) {

View file

@ -2884,7 +2884,7 @@ class FormHelper extends AppHelper {
* @return array inputDefaults
*/
public function inputDefaults($defaults = null, $merge = false) {
if (!is_null($defaults)) {
if ($defaults !== null) {
if ($merge) {
$this->_inputDefaults = array_merge($this->_inputDefaults, (array)$defaults);
} else {

View file

@ -260,7 +260,7 @@ class RssHelper extends AppHelper {
default:
$attrib = $att;
}
if (!is_null($val) && $escape) {
if ($val !== null && $escape) {
$val = h($val);
}
$elements[$key] = $this->elem($key, $attrib, $val);

View file

@ -58,7 +58,7 @@ class ScaffoldView extends View {
$scaffoldAction = 'scaffold.' . $name;
if (!is_null($this->subDir)) {
if ($this->subDir !== null) {
$subDir = strtolower($this->subDir) . DS;
} else {
$subDir = null;

View file

@ -972,7 +972,7 @@ class View extends Object {
protected function _getViewFileName($name = null) {
$subDir = null;
if (!is_null($this->subDir)) {
if ($this->subDir !== null) {
$subDir = $this->subDir . DS;
}
@ -1054,7 +1054,7 @@ class View extends Object {
}
$subDir = null;
if (!is_null($this->layoutPath)) {
if ($this->layoutPath !== null) {
$subDir = $this->layoutPath . DS;
}
list($plugin, $name) = $this->pluginSplit($name);