diff --git a/lib/Cake/Cache/Engine/ApcEngine.php b/lib/Cake/Cache/Engine/ApcEngine.php index 7b93cbb0c..58b035af2 100644 --- a/lib/Cake/Cache/Engine/ApcEngine.php +++ b/lib/Cake/Cache/Engine/ApcEngine.php @@ -61,9 +61,8 @@ class ApcEngine extends CacheEngine { * @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); diff --git a/lib/Cake/Console/Command/Task/ControllerTask.php b/lib/Cake/Console/Command/Task/ControllerTask.php index 8feecc1a5..567e288c8 100644 --- a/lib/Cake/Console/Command/Task/ControllerTask.php +++ b/lib/Cake/Console/Command/Task/ControllerTask.php @@ -419,14 +419,14 @@ class ControllerTask extends BakeTask { $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 = ''; } diff --git a/lib/Cake/Console/Command/Task/DbConfigTask.php b/lib/Cake/Console/Command/Task/DbConfigTask.php index d8be6303d..f952fbbd4 100644 --- a/lib/Cake/Console/Command/Task/DbConfigTask.php +++ b/lib/Cake/Console/Command/Task/DbConfigTask.php @@ -95,7 +95,7 @@ class DbConfigTask extends AppShell { 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 @@ class DbConfigTask extends AppShell { } $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 @@ class DbConfigTask extends AppShell { } $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 @@ class DbConfigTask extends AppShell { } $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 @@ class DbConfigTask extends AppShell { } $encoding = ''; - while ($encoding == '') { + while (!$encoding) { $encoding = $this->in(__d('cake_console', 'Table encoding?'), null, 'n'); } if (strtolower($encoding) == 'n') { @@ -170,7 +170,7 @@ class DbConfigTask extends AppShell { $schema = ''; if ($datasource == 'postgres') { - while ($schema == '') { + while (!$schema) { $schema = $this->in(__d('cake_console', 'Table schema?'), null, 'n'); } } diff --git a/lib/Cake/Console/Command/Task/ExtractTask.php b/lib/Cake/Console/Command/Task/ExtractTask.php index 8d0777be9..37af29d49 100644 --- a/lib/Cake/Console/Command/Task/ExtractTask.php +++ b/lib/Cake/Console/Command/Task/ExtractTask.php @@ -391,7 +391,7 @@ class ExtractTask extends AppShell { $position = $count; $depth = 0; - while ($depth == 0) { + while (!$depth) { if ($this->_tokens[$position] == '(') { $depth++; } elseif ($this->_tokens[$position] == ')') { @@ -591,7 +591,7 @@ class ExtractTask extends AppShell { ); 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; diff --git a/lib/Cake/Console/Command/Task/ModelTask.php b/lib/Cake/Console/Command/Task/ModelTask.php index cc7a5b3f5..b13330d6f 100644 --- a/lib/Cake/Console/Command/Task/ModelTask.php +++ b/lib/Cake/Console/Command/Task/ModelTask.php @@ -700,7 +700,7 @@ class ModelTask extends BakeTask { $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 @@ class ModelTask extends BakeTask { $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 @@ class ModelTask extends BakeTask { $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; } /** diff --git a/lib/Cake/Console/Command/Task/ProjectTask.php b/lib/Cake/Console/Command/Task/ProjectTask.php index 3935a826d..769ec5e1d 100644 --- a/lib/Cake/Console/Command/Task/ProjectTask.php +++ b/lib/Cake/Console/Command/Task/ProjectTask.php @@ -349,10 +349,7 @@ class ProjectTask extends AppShell { if (!file_put_contents($filename, $result)) { return false; } - if ($count == 0) { - return false; - } - return true; + return (bool)$count; } /** @@ -409,7 +406,7 @@ class ProjectTask extends AppShell { $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) { diff --git a/lib/Cake/Console/Command/Task/ViewTask.php b/lib/Cake/Console/Command/Task/ViewTask.php index 8baf4263e..2854c4aa8 100644 --- a/lib/Cake/Console/Command/Task/ViewTask.php +++ b/lib/Cake/Console/Command/Task/ViewTask.php @@ -316,9 +316,9 @@ class ViewTask extends BakeTask { */ 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.')); } } diff --git a/lib/Cake/Console/ConsoleErrorHandler.php b/lib/Cake/Console/ConsoleErrorHandler.php index 043c62125..3000911ef 100644 --- a/lib/Cake/Console/ConsoleErrorHandler.php +++ b/lib/Cake/Console/ConsoleErrorHandler.php @@ -81,7 +81,7 @@ class ConsoleErrorHandler { $message = __d('cake_console', '%s in [%s, line %s]', $description, $file, $line); $stderr->write(__d('cake_console', "%s Error: %s\n", $name, $message)); - if (Configure::read('debug') == 0) { + if (!Configure::read('debug')) { CakeLog::write($log, $message); } } diff --git a/lib/Cake/Controller/Component/Acl/PhpAcl.php b/lib/Cake/Controller/Component/Acl/PhpAcl.php index 6540b935b..eef48e976 100644 --- a/lib/Cake/Controller/Component/Acl/PhpAcl.php +++ b/lib/Cake/Controller/Component/Acl/PhpAcl.php @@ -170,11 +170,11 @@ class PhpAcl extends Object implements AclInterface { 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)); } } } diff --git a/lib/Cake/Controller/Component/CookieComponent.php b/lib/Cake/Controller/Component/CookieComponent.php index 45551a8af..48ab51440 100644 --- a/lib/Cake/Controller/Component/CookieComponent.php +++ b/lib/Cake/Controller/Component/CookieComponent.php @@ -381,7 +381,7 @@ class CookieComponent extends Component { } $this->_reset = $this->_expires; - if ($expires == 0) { + if (!$expires) { return $this->_expires = 0; } diff --git a/lib/Cake/Error/ExceptionRenderer.php b/lib/Cake/Error/ExceptionRenderer.php index fb55b3ad6..c45a1e2b7 100644 --- a/lib/Cake/Error/ExceptionRenderer.php +++ b/lib/Cake/Error/ExceptionRenderer.php @@ -119,7 +119,7 @@ class ExceptionRenderer { } } - if (Configure::read('debug') == 0) { + if (!Configure::read('debug')) { if ($method == '_cakeError') { $method = 'error400'; } @@ -205,7 +205,7 @@ class ExceptionRenderer { */ 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 @@ class ExceptionRenderer { */ 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(); diff --git a/lib/Cake/I18n/I18n.php b/lib/Cake/I18n/I18n.php index 7678ba6ae..e79b7a9f8 100644 --- a/lib/Cake/I18n/I18n.php +++ b/lib/Cake/I18n/I18n.php @@ -412,7 +412,7 @@ class I18n { $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"]); diff --git a/lib/Cake/Model/Behavior/TreeBehavior.php b/lib/Cake/Model/Behavior/TreeBehavior.php index af6957444..83c7045ea 100644 --- a/lib/Cake/Model/Behavior/TreeBehavior.php +++ b/lib/Cake/Model/Behavior/TreeBehavior.php @@ -798,7 +798,7 @@ class TreeBehavior extends ModelBehavior { $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'); diff --git a/lib/Cake/Model/Datasource/Database/Mysql.php b/lib/Cake/Model/Datasource/Database/Mysql.php index 88fa97661..f32c05bf4 100644 --- a/lib/Cake/Model/Datasource/Database/Mysql.php +++ b/lib/Cake/Model/Datasource/Database/Mysql.php @@ -433,7 +433,7 @@ class Mysql extends DboSource { 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']; diff --git a/lib/Cake/Model/Datasource/Database/Sqlserver.php b/lib/Cake/Model/Datasource/Database/Sqlserver.php index 48b50a253..cb502832b 100644 --- a/lib/Cake/Model/Datasource/Database/Sqlserver.php +++ b/lib/Cake/Model/Datasource/Database/Sqlserver.php @@ -732,7 +732,7 @@ class Sqlserver extends DboSource { */ 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); } diff --git a/lib/Cake/Model/Datasource/DboSource.php b/lib/Cake/Model/Datasource/DboSource.php index ec0b91167..3c358f401 100644 --- a/lib/Cake/Model/Datasource/DboSource.php +++ b/lib/Cake/Model/Datasource/DboSource.php @@ -1053,7 +1053,7 @@ class DboSource extends DataSource { if ($model->recursive == -1) { $_associations = array(); - } elseif ($model->recursive == 0) { + } elseif (!$model->recursive) { unset($_associations[2], $_associations[3]); } diff --git a/lib/Cake/Model/Model.php b/lib/Cake/Model/Model.php index abb218a4f..ef987e6ee 100644 --- a/lib/Cake/Model/Model.php +++ b/lib/Cake/Model/Model.php @@ -2980,7 +2980,7 @@ class Model extends Object implements CakeEventListener { 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)); } /** diff --git a/lib/Cake/Network/Http/HttpResponse.php b/lib/Cake/Network/Http/HttpResponse.php index 08b5598f9..3be27aad3 100644 --- a/lib/Cake/Network/Http/HttpResponse.php +++ b/lib/Cake/Network/Http/HttpResponse.php @@ -108,7 +108,7 @@ class HttpResponse implements ArrayAccess { return $headers[$name]; } foreach ($headers as $key => $value) { - if (strcasecmp($key, $name) == 0) { + if (strcasecmp($key, $name) === 0) { return $value; } } diff --git a/lib/Cake/Routing/Dispatcher.php b/lib/Cake/Routing/Dispatcher.php index b10fe4ebb..3a56d87e5 100644 --- a/lib/Cake/Routing/Dispatcher.php +++ b/lib/Cake/Routing/Dispatcher.php @@ -209,7 +209,7 @@ class Dispatcher implements CakeEventListener { 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(); diff --git a/lib/Cake/TestSuite/CakeTestSuiteCommand.php b/lib/Cake/TestSuite/CakeTestSuiteCommand.php index 6d410ec79..d7ba59337 100644 --- a/lib/Cake/TestSuite/CakeTestSuiteCommand.php +++ b/lib/Cake/TestSuite/CakeTestSuiteCommand.php @@ -73,7 +73,7 @@ class CakeTestSuiteCommand extends PHPUnit_TextUI_Command { ); } - if (count($suite) == 0) { + if (!count($suite)) { $skeleton = new PHPUnit_Util_Skeleton_Test( $suite->getName(), $this->arguments['testFile'] diff --git a/lib/Cake/TestSuite/Reporter/CakeTextReporter.php b/lib/Cake/TestSuite/Reporter/CakeTextReporter.php index 1c8c20142..e127f1d02 100644 --- a/lib/Cake/TestSuite/Reporter/CakeTextReporter.php +++ b/lib/Cake/TestSuite/Reporter/CakeTextReporter.php @@ -71,10 +71,10 @@ class CakeTextReporter extends CakeBaseReporter { * @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() . diff --git a/lib/Cake/Utility/CakeNumber.php b/lib/Cake/Utility/CakeNumber.php index 3b21cbc36..3bc49cb64 100644 --- a/lib/Cake/Utility/CakeNumber.php +++ b/lib/Cake/Utility/CakeNumber.php @@ -241,7 +241,7 @@ class CakeNumber { $result = $options['before'] = $options['after'] = null; $symbolKey = 'whole'; - if ($number == 0 ) { + if (!$number) { if ($options['zero'] !== 0 ) { return $options['zero']; } diff --git a/lib/Cake/Utility/CakeTime.php b/lib/Cake/Utility/CakeTime.php index 53db5688d..f8f92fd79 100644 --- a/lib/Cake/Utility/CakeTime.php +++ b/lib/Cake/Utility/CakeTime.php @@ -766,7 +766,7 @@ class CakeTime { } } - if ($months == 0 && $years >= 1 && $diff < ($years * 31536000)) { + if (!$months && $years >= 1 && $diff < ($years * 31536000)) { $months = 11; $years--; } @@ -795,7 +795,7 @@ class CakeTime { } $diff = $futureTime - $pastTime; - if ($diff == 0) { + if (!$diff) { return __d('cake', 'just now', 'just now'); } diff --git a/lib/Cake/Utility/Debugger.php b/lib/Cake/Utility/Debugger.php index 71638f334..933244a77 100644 --- a/lib/Cake/Utility/Debugger.php +++ b/lib/Cake/Utility/Debugger.php @@ -475,7 +475,7 @@ class Debugger { case 'float': return '(float) ' . $var; case 'string': - if (trim($var) == '') { + if (!trim($var)) { return "''"; } return "'" . $var . "'"; diff --git a/lib/Cake/Utility/String.php b/lib/Cake/Utility/String.php index 026286f58..2a8fb7293 100644 --- a/lib/Cake/Utility/String.php +++ b/lib/Cake/Utility/String.php @@ -134,7 +134,7 @@ class String { } if ($tmpOffset !== -1) { $buffer .= substr($data, $offset, ($tmpOffset - $offset)); - if ($data{$tmpOffset} == $separator && $depth == 0) { + if (!$depth && $data{$tmpOffset} == $separator) { $results[] = $buffer; $buffer = ''; } else { diff --git a/lib/Cake/Utility/Validation.php b/lib/Cake/Utility/Validation.php index 43347e37d..f5b77f798 100644 --- a/lib/Cake/Utility/Validation.php +++ b/lib/Cake/Utility/Validation.php @@ -859,7 +859,7 @@ class Validation { if ($deep !== true) { return true; } - if ($check == 0) { + if (!$check) { return false; } $sum = 0; @@ -874,7 +874,7 @@ class Validation { $sum += ($number < 10) ? $number : $number - 9; } - return ($sum % 10 == 0); + return ($sum % 10 === 0); } /** diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index 592d3eab1..d9b5b6a8d 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -2228,7 +2228,7 @@ class FormHelper extends AppHelper { } elseif ($time[0] >= 12) { $meridian = 'pm'; } - if ($time[0] == 0 && $timeFormat == '12') { + if (!$time[0] && $timeFormat == '12') { $time[0] = 12; } $hour = $min = null; diff --git a/lib/Cake/View/Helper/HtmlHelper.php b/lib/Cake/View/Helper/HtmlHelper.php index 57bc376b9..c4da2a8a9 100644 --- a/lib/Cake/View/Helper/HtmlHelper.php +++ b/lib/Cake/View/Helper/HtmlHelper.php @@ -701,7 +701,7 @@ class HtmlHelper extends AppHelper { } 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 @@ class HtmlHelper extends AppHelper { 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); diff --git a/lib/Cake/View/Helper/PaginatorHelper.php b/lib/Cake/View/Helper/PaginatorHelper.php index 05a9935b1..207bad137 100644 --- a/lib/Cake/View/Helper/PaginatorHelper.php +++ b/lib/Cake/View/Helper/PaginatorHelper.php @@ -583,7 +583,7 @@ class PaginatorHelper extends AppHelper { $options); $paging = $this->params($options['model']); - if ($paging['pageCount'] == 0) { + if (!$paging['pageCount']) { $paging['pageCount'] = 1; } $start = 0;