Skip to content
This repository
Browse code

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

  • Loading branch information...
commit cf8fccae96fe9318f7f9a7e5daf0046c4f6cdc92 1 parent 1fe7913
Carl Sutton authored September 14, 2012

Showing 30 changed files with 50 additions and 52 deletions. Show diff stats Hide diff stats

  1. 2  lib/Cake/Console/Command/AclShell.php
  2. 6  lib/Cake/Console/Command/Task/DbConfigTask.php
  3. 2  lib/Cake/Console/Command/Task/ModelTask.php
  4. 2  lib/Cake/Console/Command/Task/ProjectTask.php
  5. 2  lib/Cake/Console/Command/Task/TemplateTask.php
  6. 8  lib/Cake/Console/Shell.php
  7. 2  lib/Cake/Controller/Component/Acl/IniAcl.php
  8. 2  lib/Cake/Controller/Component/SecurityComponent.php
  9. 2  lib/Cake/Controller/Controller.php
  10. 2  lib/Cake/Core/App.php
  11. 2  lib/Cake/Model/Behavior/TranslateBehavior.php
  12. 14  lib/Cake/Model/Behavior/TreeBehavior.php
  13. 2  lib/Cake/Model/Datasource/CakeSession.php
  14. 2  lib/Cake/Model/Datasource/Database/Mysql.php
  15. 4  lib/Cake/Model/Datasource/DboSource.php
  16. 6  lib/Cake/Model/Model.php
  17. 8  lib/Cake/Model/Permission.php
  18. 2  lib/Cake/Network/CakeResponse.php
  19. 2  lib/Cake/Network/Http/HttpResponse.php
  20. 2  lib/Cake/Network/Http/HttpSocket.php
  21. 2  lib/Cake/TestSuite/Fixture/CakeFixtureManager.php
  22. 6  lib/Cake/Utility/File.php
  23. 4  lib/Cake/Utility/Folder.php
  24. 2  lib/Cake/Utility/Security.php
  25. 2  lib/Cake/View/Helper.php
  26. 2  lib/Cake/View/Helper/FormHelper.php
  27. 4  lib/Cake/View/Helper/HtmlHelper.php
  28. 2  lib/Cake/View/Helper/JsHelper.php
  29. 2  lib/Cake/View/Helper/SessionHelper.php
  30. 2  lib/Cake/View/View.php
2  lib/Cake/Console/Command/AclShell.php
@@ -598,7 +598,7 @@ protected function _getParams() {
598 598
  * @return array Variables
599 599
  */
600 600
 	protected function _dataVars($type = null) {
601  
-		if ($type == null) {
  601
+		if (!$type) {
602 602
 			$type = $this->args[0];
603 603
 		}
604 604
 		$vars = array();
6  lib/Cake/Console/Command/Task/DbConfigTask.php
@@ -92,7 +92,7 @@ protected function _interactive() {
92 92
 		$done = false;
93 93
 		$dbConfigs = array();
94 94
 
95  
-		while ($done == false) {
  95
+		while (!$done) {
96 96
 			$name = '';
97 97
 
98 98
 			while ($name == '') {
@@ -136,7 +136,7 @@ protected function _interactive() {
136 136
 			$password = '';
137 137
 			$blankPassword = false;
138 138
 
139  
-			while ($password == '' && $blankPassword == false) {
  139
+			while ($password == '' && !$blankPassword) {
140 140
 				$password = $this->in(__d('cake_console', 'Password:'));
141 141
 
142 142
 				if ($password == '') {
@@ -180,7 +180,7 @@ protected function _interactive() {
180 180
 
181 181
 			$config = compact('name', 'datasource', 'persistent', 'host', 'login', 'password', 'database', 'prefix', 'encoding', 'port', 'schema');
182 182
 
183  
-			while ($this->_verify($config) == false) {
  183
+			while (!$this->_verify($config)) {
184 184
 				$this->_interactive();
185 185
 			}
186 186
 
2  lib/Cake/Console/Command/Task/ModelTask.php
@@ -780,7 +780,7 @@ protected function _generatePossibleKeys() {
780 780
  */
781 781
 	public function bake($name, $data = array()) {
782 782
 		if (is_object($name)) {
783  
-			if ($data == false) {
  783
+			if (!$data) {
784 784
 				$data = array();
785 785
 				$data['associations'] = $this->doAssociations($name);
786 786
 				$data['validate'] = $this->doValidation($name);
2  lib/Cake/Console/Command/Task/ProjectTask.php
@@ -66,7 +66,7 @@ public function execute() {
66 66
 		}
67 67
 
68 68
 		$response = false;
69  
-		while ($response == false && is_dir($project) === true && file_exists($project . 'Config' . 'core.php')) {
  69
+		while (!$response && is_dir($project) === true && file_exists($project . 'Config' . 'core.php')) {
70 70
 			$prompt = __d('cake_console', '<warning>A project already exists in this location:</warning> %s Overwrite?', $project);
71 71
 			$response = $this->in($prompt, array('y', 'n'), 'n');
72 72
 			if (strtolower($response) === 'n') {
2  lib/Cake/Console/Command/Task/TemplateTask.php
@@ -123,7 +123,7 @@ public function set($one, $two = null) {
123 123
 			$data = array($one => $two);
124 124
 		}
125 125
 
126  
-		if ($data == null) {
  126
+		if (!$data) {
127 127
 			return false;
128 128
 		}
129 129
 		$this->templateVars = $data + $this->templateVars;
8  lib/Cake/Console/Shell.php
@@ -154,7 +154,7 @@ class Shell extends Object {
154 154
  * @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell
155 155
  */
156 156
 	public function __construct($stdout = null, $stderr = null, $stdin = null) {
157  
-		if ($this->name == null) {
  157
+		if (!$this->name) {
158 158
 			$this->name = Inflector::camelize(str_replace(array('Shell', 'Task'), '', get_class($this)));
159 159
 		}
160 160
 		$this->Tasks = new TaskCollection($this);
@@ -162,13 +162,13 @@ public function __construct($stdout = null, $stderr = null, $stdin = null) {
162 162
 		$this->stdout = $stdout;
163 163
 		$this->stderr = $stderr;
164 164
 		$this->stdin = $stdin;
165  
-		if ($this->stdout == null) {
  165
+		if (!$this->stdout) {
166 166
 			$this->stdout = new ConsoleOutput('php://stdout');
167 167
 		}
168  
-		if ($this->stderr == null) {
  168
+		if (!$this->stderr) {
169 169
 			$this->stderr = new ConsoleOutput('php://stderr');
170 170
 		}
171  
-		if ($this->stdin == null) {
  171
+		if (!$this->stdin) {
172 172
 			$this->stdin = new ConsoleInput('php://stdin');
173 173
 		}
174 174
 		$this->_useLogger();
2  lib/Cake/Controller/Component/Acl/IniAcl.php
@@ -91,7 +91,7 @@ public function inherit($aro, $aco, $action = "*") {
91 91
  * @return boolean Success
92 92
  */
93 93
 	public function check($aro, $aco, $action = null) {
94  
-		if ($this->config == null) {
  94
+		if (!$this->config) {
95 95
 			$this->config = $this->readConfigFile(APP . 'Config' . DS . 'acl.ini.php');
96 96
 		}
97 97
 		$aclConfig = $this->config;
2  lib/Cake/Controller/Component/SecurityComponent.php
@@ -308,7 +308,7 @@ public function requireAuth() {
308 308
  * @throws BadRequestException
309 309
  */
310 310
 	public function blackHole(Controller $controller, $error = '') {
311  
-		if ($this->blackHoleCallback == null) {
  311
+		if (!$this->blackHoleCallback) {
312 312
 			throw new BadRequestException(__d('cake_dev', 'The request has been black-holed'));
313 313
 		}
314 314
 		return $this->_callback($controller, $this->blackHoleCallback, array($error));
2  lib/Cake/Controller/Controller.php
@@ -319,7 +319,7 @@ public function __construct($request = null, $response = null) {
319 319
 			$this->name = substr(get_class($this), 0, -10);
320 320
 		}
321 321
 
322  
-		if ($this->viewPath == null) {
  322
+		if (!$this->viewPath) {
323 323
 			$this->viewPath = $this->name;
324 324
 		}
325 325
 
2  lib/Cake/Core/App.php
@@ -607,7 +607,7 @@ public static function import($type = null, $name = null, $parent = true, $searc
607 607
 			extract($parent, EXTR_OVERWRITE);
608 608
 		}
609 609
 
610  
-		if ($name == null && $file == null) {
  610
+		if (!$name && !$file) {
611 611
 			return false;
612 612
 		}
613 613
 
2  lib/Cake/Model/Behavior/TranslateBehavior.php
@@ -328,7 +328,7 @@ public function beforeValidate(Model $Model) {
328 328
  * @return boolean true.
329 329
  */
330 330
 	public function beforeSave(Model $Model, $options = array()) {
331  
-		if (isset($options['validate']) && $options['validate'] == false) {
  331
+		if (isset($options['validate']) && !$options['validate']) {
332 332
 			unset($this->runtime[$Model->alias]['beforeSave']);
333 333
 		}
334 334
 		if (isset($this->runtime[$Model->alias]['beforeSave'])) {
14  lib/Cake/Model/Behavior/TreeBehavior.php
@@ -355,17 +355,16 @@ public function generateTreeList(Model $Model, $conditions = null, $keyPath = nu
355 355
 			$recursive = $overrideRecursive;
356 356
 		}
357 357
 
358  
-		if ($keyPath == null && $valuePath == null && $Model->hasField($Model->displayField)) {
  358
+		$fields = null;
  359
+		if (!$keyPath && !$valuePath && $Model->hasField($Model->displayField)) {
359 360
 			$fields = array($Model->primaryKey, $Model->displayField, $left, $right);
360  
-		} else {
361  
-			$fields = null;
362 361
 		}
363 362
 
364  
-		if ($keyPath == null) {
  363
+		if (!$keyPath) {
365 364
 			$keyPath = '{n}.' . $Model->alias . '.' . $Model->primaryKey;
366 365
 		}
367 366
 
368  
-		if ($valuePath == null) {
  367
+		if (!$valuePath) {
369 368
 			$valuePath = array('%s%s', '{n}.tree_prefix', '{n}.' . $Model->alias . '.' . $Model->displayField);
370 369
 
371 370
 		} elseif (is_string($valuePath)) {
@@ -645,9 +644,8 @@ public function recover(Model $Model, $mode = 'parent', $missingParentAction = n
645 644
 			$db = ConnectionManager::getDataSource($Model->useDbConfig);
646 645
 			foreach ($Model->find('all', array('conditions' => $scope, 'fields' => array($Model->primaryKey, $parent), 'order' => $left)) as $array) {
647 646
 				$path = $this->getPath($Model, $array[$Model->alias][$Model->primaryKey]);
648  
-				if ($path == null || count($path) < 2) {
649  
-					$parentId = null;
650  
-				} else {
  647
+				$parentId = null;
  648
+				if (count($path) > 1) {
651 649
 					$parentId = $path[count($path) - 2][$Model->alias][$Model->primaryKey];
652 650
 				}
653 651
 				$Model->updateAll(array($parent => $db->value($parentId, $parent)), array($Model->escapeField() => $array[$Model->alias][$Model->primaryKey]));
2  lib/Cake/Model/Datasource/CakeSession.php
@@ -248,7 +248,7 @@ public static function id($id = null) {
248 248
 	public static function delete($name) {
249 249
 		if (self::check($name)) {
250 250
 			self::_overwrite($_SESSION, Hash::remove($_SESSION, $name));
251  
-			return (self::check($name) == false);
  251
+			return !self::check($name);
252 252
 		}
253 253
 		self::_setError(2, __d('cake_dev', "%s doesn't exist", $name));
254 254
 		return false;
2  lib/Cake/Model/Datasource/Database/Mysql.php
@@ -332,7 +332,7 @@ public function update(Model $model, $fields = array(), $values = null, $conditi
332 332
 			return parent::update($model, $fields, $values, $conditions);
333 333
 		}
334 334
 
335  
-		if ($values == null) {
  335
+		if (!$values) {
336 336
 			$combined = $fields;
337 337
 		} else {
338 338
 			$combined = array_combine($fields, $values);
4  lib/Cake/Model/Datasource/DboSource.php
@@ -983,7 +983,7 @@ public function fullTableName($model, $quote = true, $schema = true) {
983 983
 	public function create(Model $model, $fields = null, $values = null) {
984 984
 		$id = null;
985 985
 
986  
-		if ($fields == null) {
  986
+		if (!$fields) {
987 987
 			unset($fields, $values);
988 988
 			$fields = array_keys($model->data);
989 989
 			$values = array_values($model->data);
@@ -1820,7 +1820,7 @@ protected function _mergeConditions($query, $assoc) {
1820 1820
  * @return boolean Success
1821 1821
  */
1822 1822
 	public function update(Model $model, $fields = array(), $values = null, $conditions = null) {
1823  
-		if ($values == null) {
  1823
+		if (!$values) {
1824 1824
 			$combined = $fields;
1825 1825
 		} else {
1826 1826
 			$combined = array_combine($fields, $values);
6  lib/Cake/Model/Model.php
@@ -716,7 +716,7 @@ public function __construct($id = false, $table = null, $ds = null) {
716 716
 				$this->useTable = Inflector::tableize($this->name);
717 717
 			}
718 718
 
719  
-			if ($this->displayField == null) {
  719
+			if (!$this->displayField) {
720 720
 				unset($this->displayField);
721 721
 			}
722 722
 			$this->table = $this->useTable;
@@ -1443,7 +1443,7 @@ public function isVirtualField($field) {
1443 1443
  *    or false if none $field exist.
1444 1444
  */
1445 1445
 	public function getVirtualField($field = null) {
1446  
-		if ($field == null) {
  1446
+		if (!$field) {
1447 1447
 			return empty($this->virtualFields) ? false : $this->virtualFields;
1448 1448
 		}
1449 1449
 		if ($this->isVirtualField($field)) {
@@ -3197,7 +3197,7 @@ public function associations() {
3197 3197
  * @return array Associations
3198 3198
  */
3199 3199
 	public function getAssociated($type = null) {
3200  
-		if ($type == null) {
  3200
+		if (!$type) {
3201 3201
 			$associated = array();
3202 3202
 			foreach ($this->_associations as $assoc) {
3203 3203
 				if (!empty($this->{$assoc})) {
8  lib/Cake/Model/Permission.php
@@ -81,7 +81,7 @@ public function __construct() {
81 81
  * @return boolean Success (true if ARO has access to action in ACO, false otherwise)
82 82
  */
83 83
 	public function check($aro, $aco, $action = "*") {
84  
-		if ($aro == null || $aco == null) {
  84
+		if (!$aro || !$aco) {
85 85
 			return false;
86 86
 		}
87 87
 
@@ -89,12 +89,12 @@ public function check($aro, $aco, $action = "*") {
89 89
 		$aroPath = $this->Aro->node($aro);
90 90
 		$acoPath = $this->Aco->node($aco);
91 91
 
92  
-		if (empty($aroPath) || empty($acoPath)) {
  92
+		if (!$aroPath || !$acoPath) {
93 93
 			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);
94 94
 			return false;
95 95
 		}
96 96
 
97  
-		if ($acoPath == null || $acoPath == array()) {
  97
+		if (!$acoPath) {
98 98
 			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);
99 99
 			return false;
100 100
 		}
@@ -171,7 +171,7 @@ public function allow($aro, $aco, $actions = "*", $value = 1) {
171 171
 		$permKeys = $this->getAcoKeys($this->schema());
172 172
 		$save = array();
173 173
 
174  
-		if ($perms == false) {
  174
+		if (!$perms) {
175 175
 			trigger_error(__d('cake_dev', 'DbAcl::allow() - Invalid node'), E_USER_WARNING);
176 176
 			return false;
177 177
 		}
2  lib/Cake/Network/CakeResponse.php
@@ -789,7 +789,7 @@ public function sharable($public = null, $time = null) {
789 789
 			unset($this->_cacheDirectives['public']);
790 790
 			$this->maxAge($time);
791 791
 		}
792  
-		if ($time == null) {
  792
+		if (!$time) {
793 793
 			$this->_setCacheControl();
794 794
 		}
795 795
 		return (bool)$public;
2  lib/Cake/Network/Http/HttpResponse.php
@@ -361,7 +361,7 @@ protected function _tokenEscapeChars($hex = true, $chars = null) {
361 361
 			$escape[] = chr(127);
362 362
 		}
363 363
 
364  
-		if ($hex == false) {
  364
+		if (!$hex) {
365 365
 			return $escape;
366 366
 		}
367 367
 		foreach ($escape as $key => $char) {
2  lib/Cake/Network/Http/HttpSocket.php
@@ -944,7 +944,7 @@ protected function _tokenEscapeChars($hex = true, $chars = null) {
944 944
 			$escape[] = chr(127);
945 945
 		}
946 946
 
947  
-		if ($hex == false) {
  947
+		if (!$hex) {
948 948
 			return $escape;
949 949
 		}
950 950
 		foreach ($escape as $key => $char) {
2  lib/Cake/TestSuite/Fixture/CakeFixtureManager.php
@@ -200,7 +200,7 @@ public function load(CakeTestCase $test) {
200 200
 			return;
201 201
 		}
202 202
 		$fixtures = $test->fixtures;
203  
-		if (empty($fixtures) || $test->autoFixtures == false) {
  203
+		if (empty($fixtures) || !$test->autoFixtures) {
204 204
 			return;
205 205
 		}
206 206
 
6  lib/Cake/Utility/File.php
@@ -302,7 +302,7 @@ public function delete() {
302 302
  * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::info
303 303
  */
304 304
 	public function info() {
305  
-		if ($this->info == null) {
  305
+		if (!$this->info) {
306 306
 			$this->info = pathinfo($this->path);
307 307
 		}
308 308
 		if (!isset($this->info['filename'])) {
@@ -324,7 +324,7 @@ public function info() {
324 324
  * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::ext
325 325
  */
326 326
 	public function ext() {
327  
-		if ($this->info == null) {
  327
+		if (!$this->info) {
328 328
 			$this->info();
329 329
 		}
330 330
 		if (isset($this->info['extension'])) {
@@ -340,7 +340,7 @@ public function ext() {
340 340
  * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::name
341 341
  */
342 342
 	public function name() {
343  
-		if ($this->info == null) {
  343
+		if (!$this->info) {
344 344
 			$this->info();
345 345
 		}
346 346
 		if (isset($this->info['extension'])) {
4  lib/Cake/Utility/Folder.php
@@ -23,7 +23,7 @@ class Folder {
23 23
 
24 24
 /**
25 25
  * Default scheme for Folder::copy
26  
- * Recursively merges subfolders with the same name 
  26
+ * Recursively merges subfolders with the same name
27 27
  *
28 28
  * @constant MERGE
29 29
  */
@@ -425,7 +425,7 @@ public function chmod($path, $mode = false, $recursive = true, $exceptions = arr
425 425
  * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::tree
426 426
  */
427 427
 	public function tree($path = null, $exceptions = false, $type = null) {
428  
-		if ($path == null) {
  428
+		if (!$path) {
429 429
 			$path = $this->path;
430 430
 		}
431 431
 		$files = array();
2  lib/Cake/Utility/Security.php
@@ -108,7 +108,7 @@ public static function hash($string, $type = null, $salt = false) {
108 108
 			}
109 109
 		}
110 110
 
111  
-		if ($type == 'sha1' || $type == null) {
  111
+		if (!$type || $type == 'sha1') {
112 112
 			if (function_exists('sha1')) {
113 113
 				$return = sha1($string);
114 114
 				return $return;
2  lib/Cake/View/Helper.php
@@ -500,7 +500,7 @@ public function setEntity($entity, $setScope = false) {
500 500
 
501 501
 		// Either 'body' or 'date.month' type inputs.
502 502
 		if (
503  
-			($count === 1 && $this->_modelScope && $setScope == false) ||
  503
+			($count === 1 && $this->_modelScope && !$setScope) ||
504 504
 			(
505 505
 				$count === 2 &&
506 506
 				in_array($lastPart, $this->_fieldSuffixes) &&
2  lib/Cake/View/Helper/FormHelper.php
@@ -409,7 +409,7 @@ public function create($model = null, $options = array()) {
409 409
 		$action = $this->url($options['action']);
410 410
 		unset($options['type'], $options['action']);
411 411
 
412  
-		if ($options['default'] == false) {
  412
+		if (!$options['default']) {
413 413
 			if (!isset($options['onsubmit'])) {
414 414
 				$options['onsubmit'] = '';
415 415
 			}
4  lib/Cake/View/Helper/HtmlHelper.php
@@ -359,7 +359,7 @@ public function link($title, $url = null, $options = array(), $confirmMessage =
359 359
 			$confirmMessage = str_replace("'", "\'", $confirmMessage);
360 360
 			$confirmMessage = str_replace('"', '\"', $confirmMessage);
361 361
 			$options['onclick'] = "return confirm('{$confirmMessage}');";
362  
-		} elseif (isset($options['default']) && $options['default'] == false) {
  362
+		} elseif (isset($options['default']) && !$options['default']) {
363 363
 			if (isset($options['onclick'])) {
364 364
 				$options['onclick'] .= ' event.returnValue = false; return false;';
365 365
 			} else {
@@ -441,7 +441,7 @@ public function css($path, $rel = null, $options = array()) {
441 441
 		if ($rel == 'import') {
442 442
 			$out = sprintf($this->_tags['style'], $this->_parseAttributes($options, array('inline', 'block'), '', ' '), '@import url(' . $url . ');');
443 443
 		} else {
444  
-			if ($rel == null) {
  444
+			if (!$rel) {
445 445
 				$rel = 'stylesheet';
446 446
 			}
447 447
 			$out = sprintf($this->_tags['css'], $rel, $url, $this->_parseAttributes($options, array('inline', 'block'), '', ' '));
2  lib/Cake/View/Helper/JsHelper.php
@@ -338,7 +338,7 @@ public function set($one, $two = null) {
338 338
 		} else {
339 339
 			$data = array($one => $two);
340 340
 		}
341  
-		if ($data == null) {
  341
+		if (!$data) {
342 342
 			return false;
343 343
 		}
344 344
 		$this->_jsVars = array_merge($this->_jsVars, $data);
2  lib/Cake/View/Helper/SessionHelper.php
@@ -134,7 +134,7 @@ public function flash($key = 'flash', $attrs = array()) {
134 134
 					$class = $flash['params']['class'];
135 135
 				}
136 136
 				$out = '<div id="' . $key . 'Message" class="' . $class . '">' . $message . '</div>';
137  
-			} elseif ($flash['element'] == '' || $flash['element'] == null) {
  137
+			} elseif (!$flash['element']) {
138 138
 				$out = $message;
139 139
 			} else {
140 140
 				$options = array();
2  lib/Cake/View/View.php
@@ -757,7 +757,7 @@ public function set($one, $two = null) {
757 757
 		} else {
758 758
 			$data = array($one => $two);
759 759
 		}
760  
-		if ($data == null) {
  760
+		if (!$data) {
761 761
 			return false;
762 762
 		}
763 763
 		$this->viewVars = $data + $this->viewVars;

0 notes on commit cf8fcca

Please sign in to comment.
Something went wrong with that request. Please try again.