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

This commit is contained in:
dogmatic69 2012-09-14 18:26:30 +01:00
parent 1fe791353f
commit cf8fccae96
30 changed files with 50 additions and 52 deletions

View file

@ -598,7 +598,7 @@ class AclShell extends AppShell {
* @return array Variables
*/
protected function _dataVars($type = null) {
if ($type == null) {
if (!$type) {
$type = $this->args[0];
}
$vars = array();

View file

@ -92,7 +92,7 @@ class DbConfigTask extends AppShell {
$done = false;
$dbConfigs = array();
while ($done == false) {
while (!$done) {
$name = '';
while ($name == '') {
@ -136,7 +136,7 @@ class DbConfigTask extends AppShell {
$password = '';
$blankPassword = false;
while ($password == '' && $blankPassword == false) {
while ($password == '' && !$blankPassword) {
$password = $this->in(__d('cake_console', 'Password:'));
if ($password == '') {
@ -180,7 +180,7 @@ class DbConfigTask extends AppShell {
$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 file

@ -780,7 +780,7 @@ class ModelTask extends BakeTask {
*/
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 file

@ -66,7 +66,7 @@ class ProjectTask extends AppShell {
}
$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 file

@ -123,7 +123,7 @@ class TemplateTask extends AppShell {
$data = array($one => $two);
}
if ($data == null) {
if (!$data) {
return false;
}
$this->templateVars = $data + $this->templateVars;

View file

@ -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 @@ class Shell extends Object {
$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 file

@ -91,7 +91,7 @@ class IniAcl extends Object implements AclInterface {
* @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 file

@ -308,7 +308,7 @@ class SecurityComponent extends Component {
* @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 file

@ -319,7 +319,7 @@ class Controller extends Object implements CakeEventListener {
$this->name = substr(get_class($this), 0, -10);
}
if ($this->viewPath == null) {
if (!$this->viewPath) {
$this->viewPath = $this->name;
}

View file

@ -607,7 +607,7 @@ class App {
extract($parent, EXTR_OVERWRITE);
}
if ($name == null && $file == null) {
if (!$name && !$file) {
return false;
}

View file

@ -328,7 +328,7 @@ class TranslateBehavior extends ModelBehavior {
* @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 file

@ -355,17 +355,16 @@ class TreeBehavior extends ModelBehavior {
$recursive = $overrideRecursive;
}
if ($keyPath == null && $valuePath == null && $Model->hasField($Model->displayField)) {
$fields = array($Model->primaryKey, $Model->displayField, $left, $right);
} else {
$fields = null;
if (!$keyPath && !$valuePath && $Model->hasField($Model->displayField)) {
$fields = array($Model->primaryKey, $Model->displayField, $left, $right);
}
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 @@ class TreeBehavior extends ModelBehavior {
$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 {
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 file

@ -248,7 +248,7 @@ class CakeSession {
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 file

@ -332,7 +332,7 @@ class Mysql extends DboSource {
return parent::update($model, $fields, $values, $conditions);
}
if ($values == null) {
if (!$values) {
$combined = $fields;
} else {
$combined = array_combine($fields, $values);

View file

@ -983,7 +983,7 @@ class DboSource extends DataSource {
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 @@ class DboSource extends DataSource {
* @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 file

@ -716,7 +716,7 @@ class Model extends Object implements CakeEventListener {
$this->useTable = Inflector::tableize($this->name);
}
if ($this->displayField == null) {
if (!$this->displayField) {
unset($this->displayField);
}
$this->table = $this->useTable;
@ -1443,7 +1443,7 @@ class Model extends Object implements CakeEventListener {
* 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 @@ class Model extends Object implements CakeEventListener {
* @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 file

@ -81,7 +81,7 @@ class Permission extends AppModel {
* @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 @@ class Permission extends AppModel {
$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 @@ class Permission extends AppModel {
$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 file

@ -789,7 +789,7 @@ class CakeResponse {
unset($this->_cacheDirectives['public']);
$this->maxAge($time);
}
if ($time == null) {
if (!$time) {
$this->_setCacheControl();
}
return (bool)$public;

View file

@ -361,7 +361,7 @@ class HttpResponse implements ArrayAccess {
$escape[] = chr(127);
}
if ($hex == false) {
if (!$hex) {
return $escape;
}
foreach ($escape as $key => $char) {

View file

@ -944,7 +944,7 @@ class HttpSocket extends CakeSocket {
$escape[] = chr(127);
}
if ($hex == false) {
if (!$hex) {
return $escape;
}
foreach ($escape as $key => $char) {

View file

@ -200,7 +200,7 @@ class CakeFixtureManager {
return;
}
$fixtures = $test->fixtures;
if (empty($fixtures) || $test->autoFixtures == false) {
if (empty($fixtures) || !$test->autoFixtures) {
return;
}

View file

@ -302,7 +302,7 @@ class File {
* @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 @@ class File {
* @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 @@ class File {
* @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 file

@ -425,7 +425,7 @@ class Folder {
* @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 file

@ -108,7 +108,7 @@ class Security {
}
}
if ($type == 'sha1' || $type == null) {
if (!$type || $type == 'sha1') {
if (function_exists('sha1')) {
$return = sha1($string);
return $return;

View file

@ -500,7 +500,7 @@ class Helper extends Object {
// 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 file

@ -409,7 +409,7 @@ class FormHelper extends AppHelper {
$action = $this->url($options['action']);
unset($options['type'], $options['action']);
if ($options['default'] == false) {
if (!$options['default']) {
if (!isset($options['onsubmit'])) {
$options['onsubmit'] = '';
}

View file

@ -359,7 +359,7 @@ class HtmlHelper extends AppHelper {
$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 @@ class HtmlHelper extends AppHelper {
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 file

@ -338,7 +338,7 @@ class JsHelper extends AppHelper {
} else {
$data = array($one => $two);
}
if ($data == null) {
if (!$data) {
return false;
}
$this->_jsVars = array_merge($this->_jsVars, $data);

View file

@ -134,7 +134,7 @@ class SessionHelper extends AppHelper {
$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 file

@ -757,7 +757,7 @@ class View extends Object {
} else {
$data = array($one => $two);
}
if ($data == null) {
if (!$data) {
return false;
}
$this->viewVars = $data + $this->viewVars;