diff --git a/src/Collection/CollectionTrait.php b/src/Collection/CollectionTrait.php index fd3bbd32730..edadf4fd1aa 100644 --- a/src/Collection/CollectionTrait.php +++ b/src/Collection/CollectionTrait.php @@ -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; diff --git a/src/Controller/Component/PaginatorComponent.php b/src/Controller/Component/PaginatorComponent.php index df20269e243..d3db2d6b5b9 100644 --- a/src/Controller/Component/PaginatorComponent.php +++ b/src/Controller/Component/PaginatorComponent.php @@ -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), diff --git a/src/Controller/Component/SecurityComponent.php b/src/Controller/Component/SecurityComponent.php index b189289dcde..841257c5345 100644 --- a/src/Controller/Component/SecurityComponent.php +++ b/src/Controller/Component/SecurityComponent.php @@ -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); } /** diff --git a/src/Core/functions.php b/src/Core/functions.php index d54cda6e7f1..fdc38ee9840 100644 --- a/src/Core/functions.php +++ b/src/Core/functions.php @@ -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); } } diff --git a/src/Database/Query.php b/src/Database/Query.php index a1de793cfff..4ebe1de5ba3 100644 --- a/src/Database/Query.php +++ b/src/Database/Query.php @@ -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; diff --git a/src/Error/BaseErrorHandler.php b/src/Error/BaseErrorHandler.php index a5b35ee8d19..4f1f5dd4fd9 100644 --- a/src/Error/BaseErrorHandler.php +++ b/src/Error/BaseErrorHandler.php @@ -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'); diff --git a/src/Error/Debugger.php b/src/Error/Debugger.php index f922b65de6d..b430899e4ec 100644 --- a/src/Error/Debugger.php +++ b/src/Error/Debugger.php @@ -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': diff --git a/src/Http/Response.php b/src/Http/Response.php index 4d5bda4cd18..f234d9b5db2 100644 --- a/src/Http/Response.php +++ b/src/Http/Response.php @@ -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')) { @@ -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); } diff --git a/src/Mailer/MailerAwareTrait.php b/src/Mailer/MailerAwareTrait.php index c0d65f78f32..ff9080e713b 100644 --- a/src/Mailer/MailerAwareTrait.php +++ b/src/Mailer/MailerAwareTrait.php @@ -47,6 +47,6 @@ protected function getMailer($name, Email $email = null) throw new MissingMailerException(compact('name')); } - return (new $className($email)); + return new $className($email); } } diff --git a/src/TestSuite/TestCase.php b/src/TestSuite/TestCase.php index ce516e478f4..229e9033d3f 100644 --- a/src/TestSuite/TestCase.php +++ b/src/TestSuite/TestCase.php @@ -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); } /** @@ -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); } /** diff --git a/src/Utility/Hash.php b/src/Utility/Hash.php index 685e460b619..24ac6dfe10f 100644 --- a/src/Utility/Hash.php +++ b/src/Utility/Hash.php @@ -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; diff --git a/src/Utility/Text.php b/src/Utility/Text.php index e3be1f212eb..06ed561978b 100644 --- a/src/Utility/Text.php +++ b/src/Utility/Text.php @@ -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; @@ -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)) { @@ -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); @@ -209,7 +209,7 @@ 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); } @@ -217,7 +217,7 @@ public static function insert($str, $data, array $options = []) $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; } /** @@ -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); } @@ -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; } diff --git a/src/Validation/Validation.php b/src/Validation/Validation.php index da3329da63c..eabab2b151a 100644 --- a/src/Validation/Validation.php +++ b/src/Validation/Validation.php @@ -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; diff --git a/src/View/Helper/FormHelper.php b/src/View/Helper/FormHelper.php index 628d48af8c5..2602a6fc948 100644 --- a/src/View/Helper/FormHelper.php +++ b/src/View/Helper/FormHelper.php @@ -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 @@ -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 ]; @@ -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); } diff --git a/src/View/Helper/HtmlHelper.php b/src/View/Helper/HtmlHelper.php index 40cb917598c..d92f960bf85 100644 --- a/src/View/Helper/HtmlHelper.php +++ b/src/View/Helper/HtmlHelper.php @@ -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' ]); }