Skip to content
Permalink
Browse files

SCA with Php Inspections (EA Ultimate): random fixes (CS, control flow)

  • Loading branch information...
kalessil committed Apr 27, 2018
1 parent 57b2b5b commit fd0e9b843379806af52f7d07bccd5c2bb765dff9
@@ -455,9 +455,8 @@ protected function _getInput($prompt, $options, $default)
$defaultText = "[$default] ";
}
$this->_out->write('<question>' . $prompt . "</question>$optionsText\n$defaultText> ", 0);
$result = $this->_in->read();
$result = trim($result);
$result = trim($this->_in->read());
if ($default !== null && ($result === '' || $result === null)) {
return $default;
}
@@ -551,8 +550,7 @@ public function createFile($path, $contents, $forceOverwrite = false)
if (file_exists($path) && $forceOverwrite === false) {
$this->warning("File `{$path}` exists");
$key = $this->askChoice('Do you want to overwrite?', ['y', 'n', 'a', 'q'], 'n');
$key = strtolower($key);
$key = strtolower($this->askChoice('Do you want to overwrite?', ['y', 'n', 'a', 'q'], 'n'));
if ($key === 'q') {
$this->error('Quitting.', 2);
@@ -241,8 +241,7 @@ public static function loadAll(array $options = [])
}
}
if (Configure::check('plugins')) {
$plugins = array_merge($plugins, array_keys(Configure::read('plugins')));
$plugins = array_unique($plugins);
$plugins = array_unique(array_merge($plugins, array_keys(Configure::read('plugins'))));
}
$collection = static::getCollection();
@@ -131,7 +131,7 @@ public function get($name)
*/
public function next()
{
$this->position += 1;
++$this->position;
}
/**
@@ -51,7 +51,7 @@ function h($text, $double = true, $charset = null)
} else {
$text = '(object)' . get_class($text);
}
} elseif (is_bool($text) || is_null($text) || is_int($text)) {
} elseif (is_bool($text) || is_int($text) || $text === null) {
return $text;
}
@@ -120,7 +120,7 @@ protected function _transformFunctionExpression(FunctionExpression $expression)
->setConjunction(' ,')
->iterateParts(function ($p, $key) {
if ($key === 0) {
$value = rtrim(strtolower($p), 's');
$value = strtolower(rtrim($p, 's'));
if (isset($this->_dateParts[$value])) {
$p = ['value' => '%' . $this->_dateParts[$value], 'type' => null];
}
@@ -158,7 +158,7 @@ public function rollbackTransaction()
return false;
}
return $this->_connection->rollback();
return $this->_connection->rollBack();
}
/**
@@ -120,7 +120,7 @@ protected function _convertColumn($col, $length = null, $precision = null, $scal
// SqlServer schema reflection returns double length for unicode
// columns because internally it uses UTF16/UCS2
if ($col === 'nvarchar' || $col === 'nchar' || $col === 'ntext') {
$length = $length / 2;
$length /= 2;
}
if (strpos($col, 'varchar') !== false && $length < 0) {
return ['type' => TableSchema::TYPE_TEXT, 'length' => null];
@@ -239,7 +239,7 @@ public function fetchColumn($position)
$result = $this->fetch(static::FETCH_TYPE_NUM);
if (isset($result[$position])) {
return $result[$position];
};
}
return false;
}
@@ -1356,7 +1356,7 @@ public function source($alias = null)
get_called_class() . '::source() is deprecated. ' .
'Use setSource()/getSource() instead.'
);
if (is_null($alias)) {
if ($alias === null) {
return $this->getSource();
}
@@ -366,8 +366,7 @@ public function listeners($eventKey)
$globalListeners = static::instance()->prioritisedListeners($eventKey);
$globalListeners = empty($globalListeners) ? [] : $globalListeners;
$priorities = array_merge(array_keys($globalListeners), array_keys($localListeners));
$priorities = array_unique($priorities);
$priorities = array_unique(array_merge(array_keys($globalListeners), array_keys($localListeners)));
asort($priorities);
$result = [];
@@ -592,7 +592,7 @@ protected function _setContentType()
if ($charset) {
$this->_setHeader('Content-Type', "{$this->_contentType}; charset={$this->_charset}");
} else {
$this->_setHeader('Content-Type', "{$this->_contentType}");
$this->_setHeader('Content-Type', (string)$this->_contentType);
}
}
@@ -342,7 +342,7 @@ protected function _prepareMessage($email)
$lines = $email->message();
$messages = [];
foreach ($lines as $line) {
if ((!empty($line)) && ($line[0] === '.')) {
if (!empty($line) && ($line[0] === '.')) {
$messages[] = '.' . $line;
} else {
$messages[] = $line;
@@ -905,7 +905,7 @@ protected function _sync($shift, $dir, $conditions, $mark = false)
$exp = $query->newExpr();
$movement = clone $exp;
$movement->add($field)->add("$shift")->setConjunction($dir);
$movement->add($field)->add((string)$shift)->setConjunction($dir);
$inverse = clone $exp;
$movement = $mark ?
@@ -49,7 +49,7 @@ protected function _welcome()
$this->hr();
$this->out(sprintf('App : %s', APP_DIR));
$this->out(sprintf('Path: %s', APP));
$this->out(sprintf('PHP : %s', phpversion()));
$this->out(sprintf('PHP : %s', PHP_VERSION));
$this->hr();
}
@@ -712,8 +712,7 @@ public static function expand(array $data, $separator = '.')
{
$result = [];
foreach ($data as $flat => $value) {
$keys = explode($separator, $flat);
$keys = array_reverse($keys);
$keys = array_reverse(explode($separator, $flat));
$child = [
$keys[0] => $value
];
@@ -878,7 +878,7 @@ public static function excerpt($text, $phrase, $radius = 100, $ellipsis = '...')
$phraseLen = mb_strlen($phrase);
$textLen = mb_strlen($text);
$pos = mb_strpos(mb_strtolower($text), mb_strtolower($phrase));
$pos = mb_stripos($text, $phrase);
if ($pos === false) {
return mb_substr($text, 0, $radius) . $ellipsis;
}
@@ -1465,7 +1465,7 @@ protected function _magicOptions($fieldName, $options, $allowOverride)
if ($allowOverride && substr($fieldName, -5) === '._ids') {
$options['type'] = 'select';
if ((!isset($options['multiple']) || ($options['multiple'] && $options['multiple'] != 'checkbox'))) {
if (!isset($options['multiple']) || ($options['multiple'] && $options['multiple'] != 'checkbox')) {
$options['multiple'] = true;
}
}
@@ -355,8 +355,7 @@ public function link($title, $url = null, array $options = [])
unset($options['fullBase']);
} else {
$url = $this->Url->build($title);
$title = htmlspecialchars_decode($url, ENT_QUOTES);
$title = h(urldecode($title));
$title = h(urldecode(htmlspecialchars_decode($url, ENT_QUOTES)));
$escapeTitle = false;
}

0 comments on commit fd0e9b8

Please sign in to comment.
You can’t perform that action at this time.