Skip to content

Commit

Permalink
converting $foo == null / $foo == false to !$foo
Browse files Browse the repository at this point in the history
  • Loading branch information
dogmatic69 committed Sep 14, 2012
1 parent 1fe7913 commit cf8fcca
Show file tree
Hide file tree
Showing 30 changed files with 50 additions and 52 deletions.
2 changes: 1 addition & 1 deletion lib/Cake/Console/Command/AclShell.php
Expand Up @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions lib/Cake/Console/Command/Task/DbConfigTask.php
Expand Up @@ -92,7 +92,7 @@ protected function _interactive() {
$done = false;
$dbConfigs = array();

while ($done == false) {
while (!$done) {
$name = '';

while ($name == '') {
Expand Down Expand Up @@ -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 == '') {
Expand Down Expand Up @@ -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();
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Console/Command/Task/ModelTask.php
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Console/Command/Task/ProjectTask.php
Expand Up @@ -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') {
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Console/Command/Task/TemplateTask.php
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions lib/Cake/Console/Shell.php
Expand Up @@ -154,21 +154,21 @@ 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);

$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();
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Controller/Component/Acl/IniAcl.php
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Controller/Component/SecurityComponent.php
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Controller/Controller.php
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Core/App.php
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Model/Behavior/TranslateBehavior.php
Expand Up @@ -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'])) {
Expand Down
14 changes: 6 additions & 8 deletions lib/Cake/Model/Behavior/TreeBehavior.php
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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]));
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Model/Datasource/CakeSession.php
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Model/Datasource/Database/Mysql.php
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/Model/Datasource/DboSource.php
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions lib/Cake/Model/Model.php
Expand Up @@ -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;
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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})) {
Expand Down
8 changes: 4 additions & 4 deletions lib/Cake/Model/Permission.php
Expand Up @@ -81,20 +81,20 @@ 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;
}

$permKeys = $this->getAcoKeys($this->schema());
$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;
}
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Network/CakeResponse.php
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Network/Http/HttpResponse.php
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Network/Http/HttpSocket.php
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/TestSuite/Fixture/CakeFixtureManager.php
Expand Up @@ -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;
}

Expand Down
6 changes: 3 additions & 3 deletions lib/Cake/Utility/File.php
Expand Up @@ -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'])) {
Expand All @@ -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'])) {
Expand All @@ -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'])) {
Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/Utility/Folder.php
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Utility/Security.php
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/View/Helper.php
Expand Up @@ -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) &&
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/View/Helper/FormHelper.php
Expand Up @@ -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'] = '';
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/View/Helper/HtmlHelper.php
Expand Up @@ -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 {
Expand Down Expand Up @@ -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'), '', ' '));
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/View/Helper/JsHelper.php
Expand Up @@ -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);
Expand Down

0 comments on commit cf8fcca

Please sign in to comment.