Skip to content

Commit

Permalink
Removing unnecessary parentheses
Browse files Browse the repository at this point in the history
  • Loading branch information
Theaxiom committed Apr 17, 2017
1 parent 534fb76 commit 526ebe0
Show file tree
Hide file tree
Showing 15 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/Collection/CollectionTrait.php
Expand Up @@ -369,7 +369,7 @@ public function combine($keyPath, $valuePath, $groupPath = null)
$rowKey = $options['keyPath'];
$rowVal = $options['valuePath'];

if (!($options['groupPath'])) {
if (!$options['groupPath']) {
$mapReduce->emit($rowVal($value, $key), $rowKey($value, $key));

return null;
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/Component/PaginatorComponent.php
Expand Up @@ -214,8 +214,8 @@ public function paginate($object, array $settings = [])
'current' => $numResults,
'count' => $count,
'perPage' => $limit,
'prevPage' => ($page > 1),
'nextPage' => ($count > ($page * $limit)),
'prevPage' => $page > 1,
'nextPage' => $count > ($page * $limit),
'pageCount' => $pageCount,
'sort' => key($order),
'direction' => current($order),
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/Component/SecurityComponent.php
Expand Up @@ -220,7 +220,7 @@ protected function _requireMethod($method, $actions = [])
if (isset($actions[0]) && is_array($actions[0])) {
$actions = $actions[0];
}
$this->setConfig('require' . $method, (empty($actions)) ? ['*'] : $actions);
$this->setConfig('require' . $method, empty($actions) ? ['*'] : $actions);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Core/functions.php
Expand Up @@ -66,7 +66,7 @@ function h($text, $double = true, $charset = null)
$charset = $double;
}

return htmlspecialchars($text, ENT_QUOTES | ENT_SUBSTITUTE, ($charset) ? $charset : $defaultCharset, $double);
return htmlspecialchars($text, ENT_QUOTES | ENT_SUBSTITUTE, $charset ? $charset : $defaultCharset, $double);
}

}
Expand Down
2 changes: 1 addition & 1 deletion src/Database/Query.php
Expand Up @@ -412,7 +412,7 @@ public function distinct($on = [], $overwrite = false)
if (is_array($this->_parts['distinct'])) {
$merge = $this->_parts['distinct'];
}
$on = ($overwrite) ? array_values($on) : array_merge($merge, array_values($on));
$on = $overwrite ? array_values($on) : array_merge($merge, array_values($on));
}

$this->_parts['distinct'] = $on;
Expand Down
2 changes: 1 addition & 1 deletion src/Error/BaseErrorHandler.php
Expand Up @@ -75,7 +75,7 @@ public function register()
set_error_handler([$this, 'handleError'], $level);
set_exception_handler([$this, 'wrapAndHandleException']);
register_shutdown_function(function () {
if ((PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg')) {
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
return;
}
$megabytes = Configure::read('Error.extraFatalErrorMemory');
Expand Down
2 changes: 1 addition & 1 deletion src/Error/Debugger.php
Expand Up @@ -507,7 +507,7 @@ protected static function _export($var, $depth, $indent)
{
switch (static::getType($var)) {
case 'boolean':
return ($var) ? 'true' : 'false';
return $var ? 'true' : 'false';
case 'integer':
return '(int) ' . $var;
case 'float':
Expand Down
4 changes: 2 additions & 2 deletions src/Http/Response.php
Expand Up @@ -1682,7 +1682,7 @@ public function withVary($cacheVariances)
public function etag($hash = null, $weak = false)
{
if ($hash !== null) {
$this->_setHeader('Etag', sprintf('%s"%s"', ($weak) ? 'W/' : null, $hash));
$this->_setHeader('Etag', sprintf('%s"%s"', $weak ? 'W/' : null, $hash));
}

if ($this->hasHeader('Etag')) {
Expand Down Expand Up @@ -1715,7 +1715,7 @@ public function etag($hash = null, $weak = false)
*/
public function withEtag($hash, $weak = false)
{
$hash = sprintf('%s"%s"', ($weak) ? 'W/' : null, $hash);
$hash = sprintf('%s"%s"', $weak ? 'W/' : null, $hash);

return $this->withHeader('Etag', $hash);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Mailer/MailerAwareTrait.php
Expand Up @@ -47,6 +47,6 @@ protected function getMailer($name, Email $email = null)
throw new MissingMailerException(compact('name'));
}

return (new $className($email));
return new $className($email);
}
}
4 changes: 2 additions & 2 deletions src/TestSuite/TestCase.php
Expand Up @@ -574,7 +574,7 @@ protected static function assertWithinRange($expected, $result, $margin, $messag
{
$upper = $result + $margin;
$lower = $result - $margin;
static::assertTrue((($expected <= $upper) && ($expected >= $lower)), $message);
static::assertTrue(($expected <= $upper) && ($expected >= $lower), $message);
}

/**
Expand All @@ -590,7 +590,7 @@ protected static function assertNotWithinRange($expected, $result, $margin, $mes
{
$upper = $result + $margin;
$lower = $result - $margin;
static::assertTrue((($expected > $upper) || ($expected < $lower)), $message);
static::assertTrue(($expected > $upper) || ($expected < $lower), $message);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Utility/Hash.php
Expand Up @@ -345,7 +345,7 @@ protected static function _simpleOp($op, $data, $path, $values = null)
$count = count($path);
$last = $count - 1;
foreach ($path as $i => $key) {
if ((is_numeric($key) && (int)($key) > 0 || $key === '0') &&
if ((is_numeric($key) && (int)$key > 0 || $key === '0') &&
strpos($key, '0') !== 0
) {
$key = (int)$key;
Expand Down
14 changes: 7 additions & 7 deletions src/Utility/Text.php
Expand Up @@ -97,7 +97,7 @@ public static function tokenize($data, $separator = ',', $leftBound = '(', $righ
}
}
if ($tmpOffset !== -1) {
$buffer .= mb_substr($data, $offset, ($tmpOffset - $offset));
$buffer .= mb_substr($data, $offset, $tmpOffset - $offset);
$char = mb_substr($data, $tmpOffset, 1);
if (!$depth && $char === $separator) {
$results[] = $buffer;
Expand Down Expand Up @@ -173,7 +173,7 @@ public static function insert($str, $data, array $options = [])
$format = $options['format'];
$data = (array)$data;
if (empty($data)) {
return ($options['clean']) ? static::cleanInsert($str, $options) : $str;
return $options['clean'] ? static::cleanInsert($str, $options) : $str;
}

if (!isset($format)) {
Expand All @@ -193,7 +193,7 @@ public static function insert($str, $data, array $options = [])
$str = substr_replace($str, $val, $pos, 1);
}

return ($options['clean']) ? static::cleanInsert($str, $options) : $str;
return $options['clean'] ? static::cleanInsert($str, $options) : $str;
}

asort($data);
Expand All @@ -209,15 +209,15 @@ public static function insert($str, $data, array $options = [])
}
$dataReplacements = array_combine($hashKeys, array_values($data));
foreach ($dataReplacements as $tmpHash => $tmpValue) {
$tmpValue = (is_array($tmpValue)) ? '' : $tmpValue;
$tmpValue = is_array($tmpValue) ? '' : $tmpValue;
$str = str_replace($tmpHash, $tmpValue, $str);
}

if (!isset($options['format']) && isset($options['before'])) {
$str = str_replace($options['escape'] . $options['before'], $options['before'], $str);
}

return ($options['clean']) ? static::cleanInsert($str, $options) : $str;
return $options['clean'] ? static::cleanInsert($str, $options) : $str;
}

/**
Expand Down Expand Up @@ -491,7 +491,7 @@ public static function highlight($text, $phrase, array $options = [])
$segment = "(?![^<]+>)$segment(?![^<]+>)";
}

$with[] = (is_array($format)) ? $format[$key] : $format;
$with[] = is_array($format) ? $format[$key] : $format;
$replace[] = sprintf($options['regex'], $segment);
}

Expand Down Expand Up @@ -916,7 +916,7 @@ public static function isMultibyte($string)
$length = strlen($string);

for ($i = 0; $i < $length; $i++) {
$value = ord(($string[$i]));
$value = ord($string[$i]);
if ($value > 128) {
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Validation/Validation.php
Expand Up @@ -431,7 +431,7 @@ public static function date($check, $format = 'ymd', $regex = null)
$regex['ym'] = '%^(' . $year . $separator . $month . ')$%';
$regex['y'] = '%^(' . $fourDigitYear . ')$%';

$format = (is_array($format)) ? array_values($format) : [$format];
$format = is_array($format) ? array_values($format) : [$format];
foreach ($format as $key) {
if (static::_check($check, $regex[$key]) === true) {
return true;
Expand Down
6 changes: 3 additions & 3 deletions src/View/Helper/FormHelper.php
Expand Up @@ -391,7 +391,7 @@ public function create($context = null, array $options = [])
// Set enctype for form
case 'file':
$htmlAttributes['enctype'] = 'multipart/form-data';
$options['type'] = ($isCreate) ? 'post' : 'put';
$options['type'] = $isCreate ? 'post' : 'put';
// Move on
case 'post':
// Move on
Expand Down Expand Up @@ -1520,7 +1520,7 @@ public function checkbox($fieldName, array $options = [])
if ($options['hiddenField']) {
$hiddenOptions = [
'name' => $options['name'],
'value' => ($options['hiddenField'] !== true && $options['hiddenField'] !== '_split' ? $options['hiddenField'] : '0'),
'value' => $options['hiddenField'] !== true && $options['hiddenField'] !== '_split' ? $options['hiddenField'] : '0',
'form' => isset($options['form']) ? $options['form'] : null,
'secure' => false
];
Expand Down Expand Up @@ -2088,7 +2088,7 @@ public function multiCheckbox($fieldName, $options, array $attributes = [])
'name' => $attributes['name'],
'value' => '',
'secure' => false,
'disabled' => ($attributes['disabled'] === true || $attributes['disabled'] === 'disabled'),
'disabled' => $attributes['disabled'] === true || $attributes['disabled'] === 'disabled',
];
$hidden = $this->hidden($fieldName, $hiddenAttributes);
}
Expand Down
2 changes: 1 addition & 1 deletion src/View/Helper/HtmlHelper.php
Expand Up @@ -314,7 +314,7 @@ public function charset($charset = null)
}

return $this->formatTemplate('charset', [
'charset' => (!empty($charset) ? $charset : 'utf-8')
'charset' => !empty($charset) ? $charset : 'utf-8'
]);
}

Expand Down

0 comments on commit 526ebe0

Please sign in to comment.