mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
converting $foo == / $foo == 0 to !$foo (and a few $foo === 0)
This commit is contained in:
parent
cf8fccae96
commit
22a2e1b51e
29 changed files with 57 additions and 62 deletions
|
@ -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 {
|
||||
if ($duration) {
|
||||
$expires = time() + $duration;
|
||||
}
|
||||
apc_store($key . '_expires', $expires, $duration);
|
||||
|
|
|
@ -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 = '';
|
||||
}
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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.'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ class ConsoleErrorHandler {
|
|||
$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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -381,7 +381,7 @@ class CookieComponent extends Component {
|
|||
}
|
||||
$this->_reset = $this->_expires;
|
||||
|
||||
if ($expires == 0) {
|
||||
if (!$expires) {
|
||||
return $this->_expires = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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"]);
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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'];
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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]);
|
||||
}
|
||||
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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']
|
||||
|
|
|
@ -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() .
|
||||
|
|
|
@ -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'];
|
||||
}
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
|
||||
|
|
|
@ -475,7 +475,7 @@ class Debugger {
|
|||
case 'float':
|
||||
return '(float) ' . $var;
|
||||
case 'string':
|
||||
if (trim($var) == '') {
|
||||
if (!trim($var)) {
|
||||
return "''";
|
||||
}
|
||||
return "'" . $var . "'";
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue