Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

converting $foo == null / $foo == false to !$foo

  • Loading branch information...
commit cf8fccae96fe9318f7f9a7e5daf0046c4f6cdc92 1 parent 1fe7913
@dogmatic69 dogmatic69 authored
Showing with 50 additions and 52 deletions.
  1. +1 −1  lib/Cake/Console/Command/AclShell.php
  2. +3 −3 lib/Cake/Console/Command/Task/DbConfigTask.php
  3. +1 −1  lib/Cake/Console/Command/Task/ModelTask.php
  4. +1 −1  lib/Cake/Console/Command/Task/ProjectTask.php
  5. +1 −1  lib/Cake/Console/Command/Task/TemplateTask.php
  6. +4 −4 lib/Cake/Console/Shell.php
  7. +1 −1  lib/Cake/Controller/Component/Acl/IniAcl.php
  8. +1 −1  lib/Cake/Controller/Component/SecurityComponent.php
  9. +1 −1  lib/Cake/Controller/Controller.php
  10. +1 −1  lib/Cake/Core/App.php
  11. +1 −1  lib/Cake/Model/Behavior/TranslateBehavior.php
  12. +6 −8 lib/Cake/Model/Behavior/TreeBehavior.php
  13. +1 −1  lib/Cake/Model/Datasource/CakeSession.php
  14. +1 −1  lib/Cake/Model/Datasource/Database/Mysql.php
  15. +2 −2 lib/Cake/Model/Datasource/DboSource.php
  16. +3 −3 lib/Cake/Model/Model.php
  17. +4 −4 lib/Cake/Model/Permission.php
  18. +1 −1  lib/Cake/Network/CakeResponse.php
  19. +1 −1  lib/Cake/Network/Http/HttpResponse.php
  20. +1 −1  lib/Cake/Network/Http/HttpSocket.php
  21. +1 −1  lib/Cake/TestSuite/Fixture/CakeFixtureManager.php
  22. +3 −3 lib/Cake/Utility/File.php
  23. +2 −2 lib/Cake/Utility/Folder.php
  24. +1 −1  lib/Cake/Utility/Security.php
  25. +1 −1  lib/Cake/View/Helper.php
  26. +1 −1  lib/Cake/View/Helper/FormHelper.php
  27. +2 −2 lib/Cake/View/Helper/HtmlHelper.php
  28. +1 −1  lib/Cake/View/Helper/JsHelper.php
  29. +1 −1  lib/Cake/View/Helper/SessionHelper.php
  30. +1 −1  lib/Cake/View/View.php
View
2  lib/Cake/Console/Command/AclShell.php
@@ -598,7 +598,7 @@ protected function _getParams() {
* @return array Variables
*/
protected function _dataVars($type = null) {
- if ($type == null) {
+ if (!$type) {
$type = $this->args[0];
}
$vars = array();
View
6 lib/Cake/Console/Command/Task/DbConfigTask.php
@@ -92,7 +92,7 @@ protected function _interactive() {
$done = false;
$dbConfigs = array();
- while ($done == false) {
+ while (!$done) {
$name = '';
while ($name == '') {
@@ -136,7 +136,7 @@ protected function _interactive() {
$password = '';
$blankPassword = false;
- while ($password == '' && $blankPassword == false) {
+ while ($password == '' && !$blankPassword) {
$password = $this->in(__d('cake_console', 'Password:'));
if ($password == '') {
@@ -180,7 +180,7 @@ protected function _interactive() {
$config = compact('name', 'datasource', 'persistent', 'host', 'login', 'password', 'database', 'prefix', 'encoding', 'port', 'schema');
- while ($this->_verify($config) == false) {
+ while (!$this->_verify($config)) {
$this->_interactive();
}
View
2  lib/Cake/Console/Command/Task/ModelTask.php
@@ -780,7 +780,7 @@ protected function _generatePossibleKeys() {
*/
public function bake($name, $data = array()) {
if (is_object($name)) {
- if ($data == false) {
+ if (!$data) {
$data = array();
$data['associations'] = $this->doAssociations($name);
$data['validate'] = $this->doValidation($name);
View
2  lib/Cake/Console/Command/Task/ProjectTask.php
@@ -66,7 +66,7 @@ public function execute() {
}
$response = false;
- while ($response == false && is_dir($project) === true && file_exists($project . 'Config' . 'core.php')) {
+ while (!$response && is_dir($project) === true && file_exists($project . 'Config' . 'core.php')) {
$prompt = __d('cake_console', '<warning>A project already exists in this location:</warning> %s Overwrite?', $project);
$response = $this->in($prompt, array('y', 'n'), 'n');
if (strtolower($response) === 'n') {
View
2  lib/Cake/Console/Command/Task/TemplateTask.php
@@ -123,7 +123,7 @@ public function set($one, $two = null) {
$data = array($one => $two);
}
- if ($data == null) {
+ if (!$data) {
return false;
}
$this->templateVars = $data + $this->templateVars;
View
8 lib/Cake/Console/Shell.php
@@ -154,7 +154,7 @@ class Shell extends Object {
* @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell
*/
public function __construct($stdout = null, $stderr = null, $stdin = null) {
- if ($this->name == null) {
+ if (!$this->name) {
$this->name = Inflector::camelize(str_replace(array('Shell', 'Task'), '', get_class($this)));
}
$this->Tasks = new TaskCollection($this);
@@ -162,13 +162,13 @@ public function __construct($stdout = null, $stderr = null, $stdin = null) {
$this->stdout = $stdout;
$this->stderr = $stderr;
$this->stdin = $stdin;
- if ($this->stdout == null) {
+ if (!$this->stdout) {
$this->stdout = new ConsoleOutput('php://stdout');
}
- if ($this->stderr == null) {
+ if (!$this->stderr) {
$this->stderr = new ConsoleOutput('php://stderr');
}
- if ($this->stdin == null) {
+ if (!$this->stdin) {
$this->stdin = new ConsoleInput('php://stdin');
}
$this->_useLogger();
View
2  lib/Cake/Controller/Component/Acl/IniAcl.php
@@ -91,7 +91,7 @@ public function inherit($aro, $aco, $action = "*") {
* @return boolean Success
*/
public function check($aro, $aco, $action = null) {
- if ($this->config == null) {
+ if (!$this->config) {
$this->config = $this->readConfigFile(APP . 'Config' . DS . 'acl.ini.php');
}
$aclConfig = $this->config;
View
2  lib/Cake/Controller/Component/SecurityComponent.php
@@ -308,7 +308,7 @@ public function requireAuth() {
* @throws BadRequestException
*/
public function blackHole(Controller $controller, $error = '') {
- if ($this->blackHoleCallback == null) {
+ if (!$this->blackHoleCallback) {
throw new BadRequestException(__d('cake_dev', 'The request has been black-holed'));
}
return $this->_callback($controller, $this->blackHoleCallback, array($error));
View
2  lib/Cake/Controller/Controller.php
@@ -319,7 +319,7 @@ public function __construct($request = null, $response = null) {
$this->name = substr(get_class($this), 0, -10);
}
- if ($this->viewPath == null) {
+ if (!$this->viewPath) {
$this->viewPath = $this->name;
}
View
2  lib/Cake/Core/App.php
@@ -607,7 +607,7 @@ public static function import($type = null, $name = null, $parent = true, $searc
extract($parent, EXTR_OVERWRITE);
}
- if ($name == null && $file == null) {
+ if (!$name && !$file) {
return false;
}
View
2  lib/Cake/Model/Behavior/TranslateBehavior.php
@@ -328,7 +328,7 @@ public function beforeValidate(Model $Model) {
* @return boolean true.
*/
public function beforeSave(Model $Model, $options = array()) {
- if (isset($options['validate']) && $options['validate'] == false) {
+ if (isset($options['validate']) && !$options['validate']) {
unset($this->runtime[$Model->alias]['beforeSave']);
}
if (isset($this->runtime[$Model->alias]['beforeSave'])) {
View
14 lib/Cake/Model/Behavior/TreeBehavior.php
@@ -355,17 +355,16 @@ public function generateTreeList(Model $Model, $conditions = null, $keyPath = nu
$recursive = $overrideRecursive;
}
- if ($keyPath == null && $valuePath == null && $Model->hasField($Model->displayField)) {
+ $fields = null;
+ if (!$keyPath && !$valuePath && $Model->hasField($Model->displayField)) {
$fields = array($Model->primaryKey, $Model->displayField, $left, $right);
- } else {
- $fields = null;
}
- if ($keyPath == null) {
+ if (!$keyPath) {
$keyPath = '{n}.' . $Model->alias . '.' . $Model->primaryKey;
}
- if ($valuePath == null) {
+ if (!$valuePath) {
$valuePath = array('%s%s', '{n}.tree_prefix', '{n}.' . $Model->alias . '.' . $Model->displayField);
} elseif (is_string($valuePath)) {
@@ -645,9 +644,8 @@ public function recover(Model $Model, $mode = 'parent', $missingParentAction = n
$db = ConnectionManager::getDataSource($Model->useDbConfig);
foreach ($Model->find('all', array('conditions' => $scope, 'fields' => array($Model->primaryKey, $parent), 'order' => $left)) as $array) {
$path = $this->getPath($Model, $array[$Model->alias][$Model->primaryKey]);
- if ($path == null || count($path) < 2) {
- $parentId = null;
- } else {
+ $parentId = null;
+ if (count($path) > 1) {
$parentId = $path[count($path) - 2][$Model->alias][$Model->primaryKey];
}
$Model->updateAll(array($parent => $db->value($parentId, $parent)), array($Model->escapeField() => $array[$Model->alias][$Model->primaryKey]));
View
2  lib/Cake/Model/Datasource/CakeSession.php
@@ -248,7 +248,7 @@ public static function id($id = null) {
public static function delete($name) {
if (self::check($name)) {
self::_overwrite($_SESSION, Hash::remove($_SESSION, $name));
- return (self::check($name) == false);
+ return !self::check($name);
}
self::_setError(2, __d('cake_dev', "%s doesn't exist", $name));
return false;
View
2  lib/Cake/Model/Datasource/Database/Mysql.php
@@ -332,7 +332,7 @@ public function update(Model $model, $fields = array(), $values = null, $conditi
return parent::update($model, $fields, $values, $conditions);
}
- if ($values == null) {
+ if (!$values) {
$combined = $fields;
} else {
$combined = array_combine($fields, $values);
View
4 lib/Cake/Model/Datasource/DboSource.php
@@ -983,7 +983,7 @@ public function fullTableName($model, $quote = true, $schema = true) {
public function create(Model $model, $fields = null, $values = null) {
$id = null;
- if ($fields == null) {
+ if (!$fields) {
unset($fields, $values);
$fields = array_keys($model->data);
$values = array_values($model->data);
@@ -1820,7 +1820,7 @@ protected function _mergeConditions($query, $assoc) {
* @return boolean Success
*/
public function update(Model $model, $fields = array(), $values = null, $conditions = null) {
- if ($values == null) {
+ if (!$values) {
$combined = $fields;
} else {
$combined = array_combine($fields, $values);
View
6 lib/Cake/Model/Model.php
@@ -716,7 +716,7 @@ public function __construct($id = false, $table = null, $ds = null) {
$this->useTable = Inflector::tableize($this->name);
}
- if ($this->displayField == null) {
+ if (!$this->displayField) {
unset($this->displayField);
}
$this->table = $this->useTable;
@@ -1443,7 +1443,7 @@ public function isVirtualField($field) {
* or false if none $field exist.
*/
public function getVirtualField($field = null) {
- if ($field == null) {
+ if (!$field) {
return empty($this->virtualFields) ? false : $this->virtualFields;
}
if ($this->isVirtualField($field)) {
@@ -3197,7 +3197,7 @@ public function associations() {
* @return array Associations
*/
public function getAssociated($type = null) {
- if ($type == null) {
+ if (!$type) {
$associated = array();
foreach ($this->_associations as $assoc) {
if (!empty($this->{$assoc})) {
View
8 lib/Cake/Model/Permission.php
@@ -81,7 +81,7 @@ public function __construct() {
* @return boolean Success (true if ARO has access to action in ACO, false otherwise)
*/
public function check($aro, $aco, $action = "*") {
- if ($aro == null || $aco == null) {
+ if (!$aro || !$aco) {
return false;
}
@@ -89,12 +89,12 @@ public function check($aro, $aco, $action = "*") {
$aroPath = $this->Aro->node($aro);
$acoPath = $this->Aco->node($aco);
- if (empty($aroPath) || empty($acoPath)) {
+ if (!$aroPath || !$acoPath) {
trigger_error(__d('cake_dev', "DbAcl::check() - Failed ARO/ACO node lookup in permissions check. Node references:\nAro: ") . print_r($aro, true) . "\nAco: " . print_r($aco, true), E_USER_WARNING);
return false;
}
- if ($acoPath == null || $acoPath == array()) {
+ if (!$acoPath) {
trigger_error(__d('cake_dev', "DbAcl::check() - Failed ACO node lookup in permissions check. Node references:\nAro: ") . print_r($aro, true) . "\nAco: " . print_r($aco, true), E_USER_WARNING);
return false;
}
@@ -171,7 +171,7 @@ public function allow($aro, $aco, $actions = "*", $value = 1) {
$permKeys = $this->getAcoKeys($this->schema());
$save = array();
- if ($perms == false) {
+ if (!$perms) {
trigger_error(__d('cake_dev', 'DbAcl::allow() - Invalid node'), E_USER_WARNING);
return false;
}
View
2  lib/Cake/Network/CakeResponse.php
@@ -789,7 +789,7 @@ public function sharable($public = null, $time = null) {
unset($this->_cacheDirectives['public']);
$this->maxAge($time);
}
- if ($time == null) {
+ if (!$time) {
$this->_setCacheControl();
}
return (bool)$public;
View
2  lib/Cake/Network/Http/HttpResponse.php
@@ -361,7 +361,7 @@ protected function _tokenEscapeChars($hex = true, $chars = null) {
$escape[] = chr(127);
}
- if ($hex == false) {
+ if (!$hex) {
return $escape;
}
foreach ($escape as $key => $char) {
View
2  lib/Cake/Network/Http/HttpSocket.php
@@ -944,7 +944,7 @@ protected function _tokenEscapeChars($hex = true, $chars = null) {
$escape[] = chr(127);
}
- if ($hex == false) {
+ if (!$hex) {
return $escape;
}
foreach ($escape as $key => $char) {
View
2  lib/Cake/TestSuite/Fixture/CakeFixtureManager.php
@@ -200,7 +200,7 @@ public function load(CakeTestCase $test) {
return;
}
$fixtures = $test->fixtures;
- if (empty($fixtures) || $test->autoFixtures == false) {
+ if (empty($fixtures) || !$test->autoFixtures) {
return;
}
View
6 lib/Cake/Utility/File.php
@@ -302,7 +302,7 @@ public function delete() {
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::info
*/
public function info() {
- if ($this->info == null) {
+ if (!$this->info) {
$this->info = pathinfo($this->path);
}
if (!isset($this->info['filename'])) {
@@ -324,7 +324,7 @@ public function info() {
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::ext
*/
public function ext() {
- if ($this->info == null) {
+ if (!$this->info) {
$this->info();
}
if (isset($this->info['extension'])) {
@@ -340,7 +340,7 @@ public function ext() {
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::name
*/
public function name() {
- if ($this->info == null) {
+ if (!$this->info) {
$this->info();
}
if (isset($this->info['extension'])) {
View
4 lib/Cake/Utility/Folder.php
@@ -23,7 +23,7 @@ class Folder {
/**
* Default scheme for Folder::copy
- * Recursively merges subfolders with the same name
+ * Recursively merges subfolders with the same name
*
* @constant MERGE
*/
@@ -425,7 +425,7 @@ public function chmod($path, $mode = false, $recursive = true, $exceptions = arr
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::tree
*/
public function tree($path = null, $exceptions = false, $type = null) {
- if ($path == null) {
+ if (!$path) {
$path = $this->path;
}
$files = array();
View
2  lib/Cake/Utility/Security.php
@@ -108,7 +108,7 @@ public static function hash($string, $type = null, $salt = false) {
}
}
- if ($type == 'sha1' || $type == null) {
+ if (!$type || $type == 'sha1') {
if (function_exists('sha1')) {
$return = sha1($string);
return $return;
View
2  lib/Cake/View/Helper.php
@@ -500,7 +500,7 @@ public function setEntity($entity, $setScope = false) {
// Either 'body' or 'date.month' type inputs.
if (
- ($count === 1 && $this->_modelScope && $setScope == false) ||
+ ($count === 1 && $this->_modelScope && !$setScope) ||
(
$count === 2 &&
in_array($lastPart, $this->_fieldSuffixes) &&
View
2  lib/Cake/View/Helper/FormHelper.php
@@ -409,7 +409,7 @@ public function create($model = null, $options = array()) {
$action = $this->url($options['action']);
unset($options['type'], $options['action']);
- if ($options['default'] == false) {
+ if (!$options['default']) {
if (!isset($options['onsubmit'])) {
$options['onsubmit'] = '';
}
View
4 lib/Cake/View/Helper/HtmlHelper.php
@@ -359,7 +359,7 @@ public function link($title, $url = null, $options = array(), $confirmMessage =
$confirmMessage = str_replace("'", "\'", $confirmMessage);
$confirmMessage = str_replace('"', '\"', $confirmMessage);
$options['onclick'] = "return confirm('{$confirmMessage}');";
- } elseif (isset($options['default']) && $options['default'] == false) {
+ } elseif (isset($options['default']) && !$options['default']) {
if (isset($options['onclick'])) {
$options['onclick'] .= ' event.returnValue = false; return false;';
} else {
@@ -441,7 +441,7 @@ public function css($path, $rel = null, $options = array()) {
if ($rel == 'import') {
$out = sprintf($this->_tags['style'], $this->_parseAttributes($options, array('inline', 'block'), '', ' '), '@import url(' . $url . ');');
} else {
- if ($rel == null) {
+ if (!$rel) {
$rel = 'stylesheet';
}
$out = sprintf($this->_tags['css'], $rel, $url, $this->_parseAttributes($options, array('inline', 'block'), '', ' '));
View
2  lib/Cake/View/Helper/JsHelper.php
@@ -338,7 +338,7 @@ public function set($one, $two = null) {
} else {
$data = array($one => $two);
}
- if ($data == null) {
+ if (!$data) {
return false;
}
$this->_jsVars = array_merge($this->_jsVars, $data);
View
2  lib/Cake/View/Helper/SessionHelper.php
@@ -134,7 +134,7 @@ public function flash($key = 'flash', $attrs = array()) {
$class = $flash['params']['class'];
}
$out = '<div id="' . $key . 'Message" class="' . $class . '">' . $message . '</div>';
- } elseif ($flash['element'] == '' || $flash['element'] == null) {
+ } elseif (!$flash['element']) {
$out = $message;
} else {
$options = array();
View
2  lib/Cake/View/View.php
@@ -757,7 +757,7 @@ public function set($one, $two = null) {
} else {
$data = array($one => $two);
}
- if ($data == null) {
+ if (!$data) {
return false;
}
$this->viewVars = $data + $this->viewVars;
Please sign in to comment.
Something went wrong with that request. Please try again.