Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

converting $foo == / $foo == 0 to !$foo (and a few $foo === 0)

  • Loading branch information...
commit 22a2e1b51e6b5cbbfadd0b44365826053b8d6f4f 1 parent cf8fcca
@dogmatic69 dogmatic69 authored
Showing with 57 additions and 62 deletions.
  1. +2 −3 lib/Cake/Cache/Engine/ApcEngine.php
  2. +2 −2 lib/Cake/Console/Command/Task/ControllerTask.php
  3. +10 −10 lib/Cake/Console/Command/Task/DbConfigTask.php
  4. +2 −2 lib/Cake/Console/Command/Task/ExtractTask.php
  5. +6 −7 lib/Cake/Console/Command/Task/ModelTask.php
  6. +2 −5 lib/Cake/Console/Command/Task/ProjectTask.php
  7. +2 −2 lib/Cake/Console/Command/Task/ViewTask.php
  8. +1 −1  lib/Cake/Console/ConsoleErrorHandler.php
  9. +2 −2 lib/Cake/Controller/Component/Acl/PhpAcl.php
  10. +1 −1  lib/Cake/Controller/Component/CookieComponent.php
  11. +3 −3 lib/Cake/Error/ExceptionRenderer.php
  12. +1 −1  lib/Cake/I18n/I18n.php
  13. +1 −1  lib/Cake/Model/Behavior/TreeBehavior.php
  14. +1 −1  lib/Cake/Model/Datasource/Database/Mysql.php
  15. +1 −1  lib/Cake/Model/Datasource/Database/Sqlserver.php
  16. +1 −1  lib/Cake/Model/Datasource/DboSource.php
  17. +1 −1  lib/Cake/Model/Model.php
  18. +1 −1  lib/Cake/Network/Http/HttpResponse.php
  19. +1 −1  lib/Cake/Routing/Dispatcher.php
  20. +1 −1  lib/Cake/TestSuite/CakeTestSuiteCommand.php
  21. +3 −3 lib/Cake/TestSuite/Reporter/CakeTextReporter.php
  22. +1 −1  lib/Cake/Utility/CakeNumber.php
  23. +2 −2 lib/Cake/Utility/CakeTime.php
  24. +1 −1  lib/Cake/Utility/Debugger.php
  25. +1 −1  lib/Cake/Utility/String.php
  26. +2 −2 lib/Cake/Utility/Validation.php
  27. +1 −1  lib/Cake/View/Helper/FormHelper.php
  28. +3 −3 lib/Cake/View/Helper/HtmlHelper.php
  29. +1 −1  lib/Cake/View/Helper/PaginatorHelper.php
View
5 lib/Cake/Cache/Engine/ApcEngine.php
@@ -61,9 +61,8 @@ public function init($settings = array()) {
* @return boolean True if the data was successfully cached, false on failure
*/
public function write($key, $value, $duration) {
- if ($duration == 0) {
- $expires = 0;
- } else {
+ $expires = 0;
+ if ($duration) {
$expires = time() + $duration;
}
apc_store($key . '_expires', $expires, $duration);
View
4 lib/Cake/Console/Command/Task/ControllerTask.php
@@ -419,14 +419,14 @@ public function getName($useDbConfig = null) {
$controllers = $this->listAll($useDbConfig);
$enteredController = '';
- while ($enteredController == '') {
+ while (!$enteredController) {
$enteredController = $this->in(__d('cake_console', "Enter a number from the list above,\ntype in the name of another controller, or 'q' to exit"), null, 'q');
if ($enteredController === 'q') {
$this->out(__d('cake_console', 'Exit'));
return $this->_stop();
}
- if ($enteredController == '' || intval($enteredController) > count($controllers)) {
+ if (!$enteredController || intval($enteredController) > count($controllers)) {
$this->err(__d('cake_console', "The Controller name you supplied was empty,\nor the number you selected was not an option. Please try again."));
$enteredController = '';
}
View
20 lib/Cake/Console/Command/Task/DbConfigTask.php
@@ -95,7 +95,7 @@ protected function _interactive() {
while (!$done) {
$name = '';
- while ($name == '') {
+ while (!$name) {
$name = $this->in(__d('cake_console', "Name:"), null, 'default');
if (preg_match('/[^a-z0-9_]/i', $name)) {
$name = '';
@@ -116,12 +116,12 @@ protected function _interactive() {
}
$host = '';
- while ($host == '') {
+ while (!$host) {
$host = $this->in(__d('cake_console', 'Database Host:'), null, 'localhost');
}
$port = '';
- while ($port == '') {
+ while (!$port) {
$port = $this->in(__d('cake_console', 'Port?'), null, 'n');
}
@@ -130,16 +130,16 @@ protected function _interactive() {
}
$login = '';
- while ($login == '') {
+ while (!$login) {
$login = $this->in(__d('cake_console', 'User:'), null, 'root');
}
$password = '';
$blankPassword = false;
- while ($password == '' && !$blankPassword) {
+ while (!$password && !$blankPassword) {
$password = $this->in(__d('cake_console', 'Password:'));
- if ($password == '') {
+ if (!$password) {
$blank = $this->in(__d('cake_console', 'The password you supplied was empty. Use an empty password?'), array('y', 'n'), 'n');
if ($blank == 'y') {
$blankPassword = true;
@@ -148,12 +148,12 @@ protected function _interactive() {
}
$database = '';
- while ($database == '') {
+ while (!$database) {
$database = $this->in(__d('cake_console', 'Database Name:'), null, 'cake');
}
$prefix = '';
- while ($prefix == '') {
+ while (!$prefix) {
$prefix = $this->in(__d('cake_console', 'Table Prefix?'), null, 'n');
}
if (strtolower($prefix) == 'n') {
@@ -161,7 +161,7 @@ protected function _interactive() {
}
$encoding = '';
- while ($encoding == '') {
+ while (!$encoding) {
$encoding = $this->in(__d('cake_console', 'Table encoding?'), null, 'n');
}
if (strtolower($encoding) == 'n') {
@@ -170,7 +170,7 @@ protected function _interactive() {
$schema = '';
if ($datasource == 'postgres') {
- while ($schema == '') {
+ while (!$schema) {
$schema = $this->in(__d('cake_console', 'Table schema?'), null, 'n');
}
}
View
4 lib/Cake/Console/Command/Task/ExtractTask.php
@@ -391,7 +391,7 @@ protected function _parse($functionName, $map) {
$position = $count;
$depth = 0;
- while ($depth == 0) {
+ while (!$depth) {
if ($this->_tokens[$position] == '(') {
$depth++;
} elseif ($this->_tokens[$position] == ')') {
@@ -591,7 +591,7 @@ protected function _writeFiles() {
);
if (strtoupper($response) === 'N') {
$response = '';
- while ($response == '') {
+ while (!$response) {
$response = $this->in(__d('cake_console', "What would you like to name this file?"), null, 'new_' . $filename);
$File = new File($this->_output . $response);
$filename = $response;
View
13 lib/Cake/Console/Command/Task/ModelTask.php
@@ -700,7 +700,7 @@ public function doMoreAssociations(Model $model, $associations) {
$alias = $this->in(__d('cake_console', 'What is the alias for this association?'));
$className = $this->in(__d('cake_console', 'What className will %s use?', $alias), null, $alias );
- if ($assocType == 0) {
+ if (!$assocType) {
if (!empty($possibleKeys[$model->table])) {
$showKeys = $possibleKeys[$model->table];
} else {
@@ -935,7 +935,7 @@ public function getName($useDbConfig = null) {
$enteredModel = '';
- while ($enteredModel == '') {
+ while (!$enteredModel) {
$enteredModel = $this->in(__d('cake_console', "Enter a number from the list above,\n" .
"type in the name of another model, or 'q' to exit"), null, 'q');
@@ -944,18 +944,17 @@ public function getName($useDbConfig = null) {
$this->_stop();
}
- if ($enteredModel == '' || intval($enteredModel) > count($this->_modelNames)) {
+ if (!$enteredModel || intval($enteredModel) > count($this->_modelNames)) {
$this->err(__d('cake_console', "The model name you supplied was empty,\n" .
"or the number you selected was not an option. Please try again."));
$enteredModel = '';
}
}
if (intval($enteredModel) > 0 && intval($enteredModel) <= count($this->_modelNames)) {
- $currentModelName = $this->_modelNames[intval($enteredModel) - 1];
- } else {
- $currentModelName = $enteredModel;
+ return $this->_modelNames[intval($enteredModel) - 1];
}
- return $currentModelName;
+
+ return $enteredModel;
}
/**
View
7 lib/Cake/Console/Command/Task/ProjectTask.php
@@ -349,10 +349,7 @@ protected function _replaceCorePath($filename, $hardCode) {
if (!file_put_contents($filename, $result)) {
return false;
}
- if ($count == 0) {
- return false;
- }
- return true;
+ return (bool)$count;
}
/**
@@ -409,7 +406,7 @@ public function getPrefix() {
$this->out(__d('cake_console', 'You need to enable Configure::write(\'Routing.prefixes\',array(\'admin\')) in /app/Config/core.php to use prefix routing.'));
$this->out(__d('cake_console', 'What would you like the prefix route to be?'));
$this->out(__d('cake_console', 'Example: www.example.com/admin/controller'));
- while ($admin == '') {
+ while (!$admin) {
$admin = $this->in(__d('cake_console', 'Enter a routing prefix:'), null, 'admin');
}
if ($this->cakeAdmin($admin) !== true) {
View
4 lib/Cake/Console/Command/Task/ViewTask.php
@@ -316,9 +316,9 @@ public function bakeActions($actions, $vars) {
*/
public function customAction() {
$action = '';
- while ($action == '') {
+ while (!$action) {
$action = $this->in(__d('cake_console', 'Action Name? (use lowercase_underscored function name)'));
- if ($action == '') {
+ if (!$action) {
$this->out(__d('cake_console', 'The action name you supplied was empty. Please try again.'));
}
}
View
2  lib/Cake/Console/ConsoleErrorHandler.php
@@ -81,7 +81,7 @@ public function handleError($code, $description, $file = null, $line = null, $co
$message = __d('cake_console', '%s in [%s, line %s]', $description, $file, $line);
$stderr->write(__d('cake_console', "<error>%s Error:</error> %s\n", $name, $message));
- if (Configure::read('debug') == 0) {
+ if (!Configure::read('debug')) {
CakeLog::write($log, $message);
}
}
View
4 lib/Cake/Controller/Component/Acl/PhpAcl.php
@@ -170,11 +170,11 @@ public function check($aro, $aco, $action = "*") {
foreach ($path as $depth => $node) {
foreach ($prioritizedAros as $aros) {
if (!empty($node['allow'])) {
- $allow = $allow || count(array_intersect($node['allow'], $aros)) > 0;
+ $allow = $allow || count(array_intersect($node['allow'], $aros));
}
if (!empty($node['deny'])) {
- $allow = $allow && count(array_intersect($node['deny'], $aros)) == 0;
+ $allow = $allow && !count(array_intersect($node['deny'], $aros));
}
}
}
View
2  lib/Cake/Controller/Component/CookieComponent.php
@@ -381,7 +381,7 @@ protected function _expire($expires = null) {
}
$this->_reset = $this->_expires;
- if ($expires == 0) {
+ if (!$expires) {
return $this->_expires = 0;
}
View
6 lib/Cake/Error/ExceptionRenderer.php
@@ -119,7 +119,7 @@ public function __construct(Exception $exception) {
}
}
- if (Configure::read('debug') == 0) {
+ if (!Configure::read('debug')) {
if ($method == '_cakeError') {
$method = 'error400';
}
@@ -205,7 +205,7 @@ protected function _cakeError(CakeException $error) {
*/
public function error400($error) {
$message = $error->getMessage();
- if (Configure::read('debug') == 0 && $error instanceof CakeException) {
+ if (!Configure::read('debug') && $error instanceof CakeException) {
$message = __d('cake', 'Not Found');
}
$url = $this->controller->request->here();
@@ -227,7 +227,7 @@ public function error400($error) {
*/
public function error500($error) {
$message = $error->getMessage();
- if (Configure::read('debug') == 0) {
+ if (!Configure::read('debug')) {
$message = __d('cake', 'An Internal Error Has Occurred.');
}
$url = $this->controller->request->here();
View
2  lib/Cake/I18n/I18n.php
@@ -412,7 +412,7 @@ public static function loadMo($filename) {
$header = unpack("L1magic/L1version/L1count/L1o_msg/L1o_trn", $header);
extract($header);
- if ((dechex($magic) == '950412de' || dechex($magic) == 'ffffffff950412de') && $version == 0) {
+ if ((dechex($magic) == '950412de' || dechex($magic) == 'ffffffff950412de') && !$version) {
for ($n = 0; $n < $count; $n++) {
$r = unpack("L1len/L1offs", substr($data, $o_msg + $n * 8, 8));
$msgid = substr($data, $r["offs"], $r["len"]);
View
2  lib/Cake/Model/Behavior/TreeBehavior.php
@@ -798,7 +798,7 @@ public function verify(Model $Model) {
$scope, 'OR' => array($Model->escapeField($left) => $i, $Model->escapeField($right) => $i)
)));
if ($count != 1) {
- if ($count == 0) {
+ if (!$count) {
$errors[] = array('index', $i, 'missing');
} else {
$errors[] = array('index', $i, 'duplicate');
View
2  lib/Cake/Model/Datasource/Database/Mysql.php
@@ -433,7 +433,7 @@ public function index($model) {
if (!isset($index[$idx->Key_name]['column'])) {
$col = array();
$index[$idx->Key_name]['column'] = $idx->Column_name;
- $index[$idx->Key_name]['unique'] = intval($idx->Non_unique == 0);
+ $index[$idx->Key_name]['unique'] = intval(!$idx->Non_unique);
} else {
if (!empty($index[$idx->Key_name]['column']) && !is_array($index[$idx->Key_name]['column'])) {
$col[] = $index[$idx->Key_name]['column'];
View
2  lib/Cake/Model/Datasource/Database/Sqlserver.php
@@ -732,7 +732,7 @@ public function lastAffected($source = null) {
*/
protected function _execute($sql, $params = array(), $prepareOptions = array()) {
$this->_lastAffected = false;
- if (strncasecmp($sql, 'SELECT', 6) == 0 || preg_match('/^EXEC(?:UTE)?\s/mi', $sql) > 0) {
+ if (strncasecmp($sql, 'SELECT', 6) === 0 || preg_match('/^EXEC(?:UTE)?\s/mi', $sql) > 0) {
$prepareOptions += array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL);
return parent::_execute($sql, $params, $prepareOptions);
}
View
2  lib/Cake/Model/Datasource/DboSource.php
@@ -1053,7 +1053,7 @@ public function read(Model $model, $queryData = array(), $recursive = null) {
if ($model->recursive == -1) {
$_associations = array();
- } elseif ($model->recursive == 0) {
+ } elseif (!$model->recursive) {
unset($_associations[2], $_associations[3]);
}
View
2  lib/Cake/Model/Model.php
@@ -2980,7 +2980,7 @@ public function isUnique($fields, $or = true) {
if (!empty($this->id)) {
$fields[$this->alias . '.' . $this->primaryKey . ' !='] = $this->id;
}
- return ($this->find('count', array('conditions' => $fields, 'recursive' => -1)) == 0);
+ return !$this->find('count', array('conditions' => $fields, 'recursive' => -1));
}
/**
View
2  lib/Cake/Network/Http/HttpResponse.php
@@ -108,7 +108,7 @@ public function getHeader($name, $headers = null) {
return $headers[$name];
}
foreach ($headers as $key => $value) {
- if (strcasecmp($key, $name) == 0) {
+ if (strcasecmp($key, $name) === 0) {
return $value;
}
}
View
2  lib/Cake/Routing/Dispatcher.php
@@ -209,7 +209,7 @@ protected function _invoke(Controller $controller, CakeRequest $request, CakeRes
public function parseParams($event) {
$request = $event->data['request'];
Router::setRequestInfo($request);
- if (count(Router::$routes) == 0) {
+ if (!count(Router::$routes)) {
$namedExpressions = Router::getNamedExpressions();
extract($namedExpressions);
$this->_loadRoutes();
View
2  lib/Cake/TestSuite/CakeTestSuiteCommand.php
@@ -73,7 +73,7 @@ public function run(array $argv, $exit = true) {
);
}
- if (count($suite) == 0) {
+ if (!count($suite)) {
$skeleton = new PHPUnit_Util_Skeleton_Test(
$suite->getName(),
$this->arguments['testFile']
View
6 lib/Cake/TestSuite/Reporter/CakeTextReporter.php
@@ -71,10 +71,10 @@ public function paintFail($message) {
* @return void
*/
public function paintFooter($result) {
- if ($result->failureCount() + $result->errorCount() == 0) {
- echo "\nOK\n";
- } else {
+ if ($result->failureCount() + $result->errorCount()) {
echo "FAILURES!!!\n";
+ } else {
+ echo "\nOK\n";
}
echo "Test cases run: " . $result->count() .
View
2  lib/Cake/Utility/CakeNumber.php
@@ -241,7 +241,7 @@ public static function currency($number, $currency = 'USD', $options = array())
$result = $options['before'] = $options['after'] = null;
$symbolKey = 'whole';
- if ($number == 0 ) {
+ if (!$number) {
if ($options['zero'] !== 0 ) {
return $options['zero'];
}
View
4 lib/Cake/Utility/CakeTime.php
@@ -766,7 +766,7 @@ public static function timeAgoInWords($dateTime, $options = array()) {
}
}
- if ($months == 0 && $years >= 1 && $diff < ($years * 31536000)) {
+ if (!$months && $years >= 1 && $diff < ($years * 31536000)) {
$months = 11;
$years--;
}
@@ -795,7 +795,7 @@ public static function timeAgoInWords($dateTime, $options = array()) {
}
$diff = $futureTime - $pastTime;
- if ($diff == 0) {
+ if (!$diff) {
return __d('cake', 'just now', 'just now');
}
View
2  lib/Cake/Utility/Debugger.php
@@ -475,7 +475,7 @@ protected static function _export($var, $depth, $indent) {
case 'float':
return '(float) ' . $var;
case 'string':
- if (trim($var) == '') {
+ if (!trim($var)) {
return "''";
}
return "'" . $var . "'";
View
2  lib/Cake/Utility/String.php
@@ -134,7 +134,7 @@ public static function tokenize($data, $separator = ',', $leftBound = '(', $righ
}
if ($tmpOffset !== -1) {
$buffer .= substr($data, $offset, ($tmpOffset - $offset));
- if ($data{$tmpOffset} == $separator && $depth == 0) {
+ if (!$depth && $data{$tmpOffset} == $separator) {
$results[] = $buffer;
$buffer = '';
} else {
View
4 lib/Cake/Utility/Validation.php
@@ -859,7 +859,7 @@ public static function luhn($check, $deep = false) {
if ($deep !== true) {
return true;
}
- if ($check == 0) {
+ if (!$check) {
return false;
}
$sum = 0;
@@ -874,7 +874,7 @@ public static function luhn($check, $deep = false) {
$sum += ($number < 10) ? $number : $number - 9;
}
- return ($sum % 10 == 0);
+ return ($sum % 10 === 0);
}
/**
View
2  lib/Cake/View/Helper/FormHelper.php
@@ -2228,7 +2228,7 @@ public function dateTime($fieldName, $dateFormat = 'DMY', $timeFormat = '12', $a
} elseif ($time[0] >= 12) {
$meridian = 'pm';
}
- if ($time[0] == 0 && $timeFormat == '12') {
+ if (!$time[0] && $timeFormat == '12') {
$time[0] = 12;
}
$hour = $min = null;
View
6 lib/Cake/View/Helper/HtmlHelper.php
@@ -701,7 +701,7 @@ public function getCrumbList($options = array(), $startText = false) {
} else {
$elementContent = $this->link($crumb[0], $crumb[1], $crumb[2]);
}
- if ($which == 0) {
+ if (!$which) {
$options['class'] = 'first';
} elseif ($which == $crumbCount - 1) {
$options['class'] = 'last';
@@ -1116,9 +1116,9 @@ protected function _nestedListItem($items, $options, $itemOptions, $tag) {
if (is_array($item)) {
$item = $key . $this->nestedList($item, $options, $itemOptions, $tag);
}
- if (isset($itemOptions['even']) && $index % 2 == 0) {
+ if (isset($itemOptions['even']) && $index % 2 === 0) {
$itemOptions['class'] = $itemOptions['even'];
- } elseif (isset($itemOptions['odd']) && $index % 2 != 0) {
+ } elseif (isset($itemOptions['odd']) && $index % 2 !== 0) {
$itemOptions['class'] = $itemOptions['odd'];
}
$out .= sprintf($this->_tags['li'], $this->_parseAttributes($itemOptions, array('even', 'odd'), ' ', ''), $item);
View
2  lib/Cake/View/Helper/PaginatorHelper.php
@@ -583,7 +583,7 @@ public function counter($options = array()) {
$options);
$paging = $this->params($options['model']);
- if ($paging['pageCount'] == 0) {
+ if (!$paging['pageCount']) {
$paging['pageCount'] = 1;
}
$start = 0;
Please sign in to comment.
Something went wrong with that request. Please try again.