Browse Source

Removing unnecessary parentheses

Travis Rowland 9 years ago
parent
commit
526ebe0ede

+ 1 - 1
src/Collection/CollectionTrait.php

@@ -369,7 +369,7 @@ trait CollectionTrait
             $rowKey = $options['keyPath'];
             $rowVal = $options['valuePath'];
 
-            if (!($options['groupPath'])) {
+            if (!$options['groupPath']) {
                 $mapReduce->emit($rowVal($value, $key), $rowKey($value, $key));
 
                 return null;

+ 2 - 2
src/Controller/Component/PaginatorComponent.php

@@ -214,8 +214,8 @@ class PaginatorComponent extends Component
             '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),

+ 1 - 1
src/Controller/Component/SecurityComponent.php

@@ -220,7 +220,7 @@ class SecurityComponent extends Component
         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);
     }
 
     /**

+ 1 - 1
src/Core/functions.php

@@ -66,7 +66,7 @@ if (!function_exists('h')) {
             $charset = $double;
         }
 
-        return htmlspecialchars($text, ENT_QUOTES | ENT_SUBSTITUTE, ($charset) ? $charset : $defaultCharset, $double);
+        return htmlspecialchars($text, ENT_QUOTES | ENT_SUBSTITUTE, $charset ? $charset : $defaultCharset, $double);
     }
 
 }

+ 1 - 1
src/Database/Query.php

@@ -412,7 +412,7 @@ class Query implements ExpressionInterface, IteratorAggregate
             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;

+ 1 - 1
src/Error/BaseErrorHandler.php

@@ -75,7 +75,7 @@ abstract class BaseErrorHandler
         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');

+ 1 - 1
src/Error/Debugger.php

@@ -507,7 +507,7 @@ class Debugger
     {
         switch (static::getType($var)) {
             case 'boolean':
-                return ($var) ? 'true' : 'false';
+                return $var ? 'true' : 'false';
             case 'integer':
                 return '(int) ' . $var;
             case 'float':

+ 2 - 2
src/Http/Response.php

@@ -1682,7 +1682,7 @@ class Response implements ResponseInterface
     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 @@ class Response implements ResponseInterface
      */
     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);
     }

+ 1 - 1
src/Mailer/MailerAwareTrait.php

@@ -47,6 +47,6 @@ trait MailerAwareTrait
             throw new MissingMailerException(compact('name'));
         }
 
-        return (new $className($email));
+        return new $className($email);
     }
 }

+ 2 - 2
src/TestSuite/TestCase.php

@@ -574,7 +574,7 @@ abstract class TestCase extends BaseTestCase
     {
         $upper = $result + $margin;
         $lower = $result - $margin;
-        static::assertTrue((($expected <= $upper) && ($expected >= $lower)), $message);
+        static::assertTrue(($expected <= $upper) && ($expected >= $lower), $message);
     }
 
     /**
@@ -590,7 +590,7 @@ abstract class TestCase extends BaseTestCase
     {
         $upper = $result + $margin;
         $lower = $result - $margin;
-        static::assertTrue((($expected > $upper) || ($expected < $lower)), $message);
+        static::assertTrue(($expected > $upper) || ($expected < $lower), $message);
     }
 
     /**

+ 1 - 1
src/Utility/Hash.php

@@ -345,7 +345,7 @@ class Hash
         $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;

+ 7 - 7
src/Utility/Text.php

@@ -97,7 +97,7 @@ class Text
                 }
             }
             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 @@ class Text
         $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 @@ class Text
                 $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 @@ class Text
         }
         $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 @@ class Text
             $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 @@ class Text
                     $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 @@ class Text
         $length = strlen($string);
 
         for ($i = 0; $i < $length; $i++) {
-            $value = ord(($string[$i]));
+            $value = ord($string[$i]);
             if ($value > 128) {
                 return true;
             }

+ 1 - 1
src/Validation/Validation.php

@@ -431,7 +431,7 @@ class Validation
         $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;

+ 3 - 3
src/View/Helper/FormHelper.php

@@ -391,7 +391,7 @@ class FormHelper extends Helper
             // 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 @@ class FormHelper extends Helper
         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 @@ class FormHelper extends Helper
                 '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);
         }

+ 1 - 1
src/View/Helper/HtmlHelper.php

@@ -314,7 +314,7 @@ class HtmlHelper extends Helper
         }
 
         return $this->formatTemplate('charset', [
-            'charset' => (!empty($charset) ? $charset : 'utf-8')
+            'charset' => !empty($charset) ? $charset : 'utf-8'
         ]);
     }