Browse Source

Using short syntax for applied operations

Travis Rowland 9 years ago
parent
commit
1b0ce56f3b

+ 1 - 1
src/Controller/Controller.php

@@ -712,7 +712,7 @@ class Controller implements EventListenerInterface, EventDispatcherInterface
         if (empty($table)) {
             throw new RuntimeException('Unable to locate an object compatible with paginate.');
         }
-        $settings = $settings + $this->paginate;
+        $settings += $this->paginate;
 
         return $this->Paginator->paginate($table, $settings);
     }

+ 2 - 2
src/Database/Schema/TableSchema.php

@@ -506,7 +506,7 @@ class TableSchema
             $attrs = ['type' => $attrs];
         }
         $attrs = array_intersect_key($attrs, static::$_indexKeys);
-        $attrs = $attrs + static::$_indexKeys;
+        $attrs += static::$_indexKeys;
         unset($attrs['references'], $attrs['update'], $attrs['delete']);
 
         if (!in_array($attrs['type'], static::$_validIndexTypes, true)) {
@@ -602,7 +602,7 @@ class TableSchema
             $attrs = ['type' => $attrs];
         }
         $attrs = array_intersect_key($attrs, static::$_indexKeys);
-        $attrs = $attrs + static::$_indexKeys;
+        $attrs += static::$_indexKeys;
         if (!in_array($attrs['type'], static::$_validConstraintTypes, true)) {
             throw new Exception(sprintf('Invalid constraint type "%s" in table "%s".', $attrs['type'], $this->_table));
         }

+ 1 - 1
src/Database/TypeMap.php

@@ -125,7 +125,7 @@ class TypeMap
      */
     public function addDefaults(array $types)
     {
-        $this->_defaults = $this->_defaults + $types;
+        $this->_defaults += $types;
     }
 
     /**

+ 1 - 1
src/Datasource/RulesChecker.php

@@ -293,7 +293,7 @@ class RulesChecker
     protected function _checkRules(EntityInterface $entity, array $options = [], array $rules = [])
     {
         $success = true;
-        $options = $options + $this->_options;
+        $options += $this->_options;
         foreach ($rules as $rule) {
             $success = $rule($entity, $options) && $success;
         }

+ 1 - 1
src/Error/BaseErrorHandler.php

@@ -244,7 +244,7 @@ abstract class BaseErrorHandler
         $units = strtoupper(substr($limit, -1));
         $current = (int)substr($limit, 0, strlen($limit) - 1);
         if ($units === 'M') {
-            $current = $current * 1024;
+            $current *= 1024;
             $units = 'K';
         }
         if ($units === 'G') {

+ 1 - 1
src/I18n/Number.php

@@ -225,7 +225,7 @@ class Number
         $formatter = static::formatter(['type' => static::FORMAT_CURRENCY] + $options);
         $abs = abs($value);
         if (!empty($options['fractionSymbol']) && $abs > 0 && $abs < 1) {
-            $value = $value * 100;
+            $value *= 100;
             $pos = isset($options['fractionPosition']) ? $options['fractionPosition'] : 'after';
 
             return static::format($value, ['precision' => 0, $pos => $options['fractionSymbol']]);

+ 7 - 7
src/I18n/RelativeTimeFormatter.php

@@ -202,7 +202,7 @@ class RelativeTimeFormatter
 
             if ($months >= 12) {
                 $years = floor($months / 12);
-                $months = $months - ($years * 12);
+                $months -= ($years * 12);
             }
             if ($future['m'] < $past['m'] && $future['Y'] - $past['Y'] === 1) {
                 $years--;
@@ -231,25 +231,25 @@ class RelativeTimeFormatter
             }
 
             if ($months >= 12) {
-                $years = $years + 1;
-                $months = $months - 12;
+                ++$years;
+                $months -= 12;
             }
 
             if ($days >= 7) {
                 $weeks = floor($days / 7);
-                $days = $days - ($weeks * 7);
+                $days -= ($weeks * 7);
             }
         } else {
             $years = $months = $weeks = 0;
             $days = floor($diff / 86400);
 
-            $diff = $diff - ($days * 86400);
+            $diff -= ($days * 86400);
 
             $hours = floor($diff / 3600);
-            $diff = $diff - ($hours * 3600);
+            $diff -= ($hours * 3600);
 
             $minutes = floor($diff / 60);
-            $diff = $diff - ($minutes * 60);
+            $diff -= ($minutes * 60);
             $seconds = $diff;
         }
 

+ 1 - 1
src/ORM/Table.php

@@ -1889,7 +1889,7 @@ class Table implements RepositoryInterface, EventListenerInterface, EventDispatc
         $primary = array_intersect_key($data, $primary) + $primary;
 
         $filteredKeys = array_filter($primary, 'strlen');
-        $data = $data + $filteredKeys;
+        $data += $filteredKeys;
 
         if (count($primary) > 1) {
             $schema = $this->getSchema();

+ 1 - 1
src/Routing/RouteBuilder.php

@@ -685,7 +685,7 @@ class RouteBuilder
         }
         unset($params['_namePrefix']);
 
-        $params = $params + $this->_params;
+        $params += $this->_params;
         $builder = new static($this->_collection, $path, $params, [
             'routeClass' => $this->_routeClass,
             'extensions' => $this->_extensions,

+ 1 - 1
src/Utility/Text.php

@@ -347,7 +347,7 @@ class Text
 
         if (!empty($options['indentAt']) && $options['indentAt'] === 0) {
             $indentLength = !empty($options['indent']) ? strlen($options['indent']) : 0;
-            $options['width'] = $options['width'] - $indentLength;
+            $options['width'] -= $indentLength;
 
             return self::wrap($text, $options);
         }

+ 1 - 1
src/View/JsonView.php

@@ -147,7 +147,7 @@ class JsonView extends SerializedView
         }
 
         if (Configure::read('debug')) {
-            $jsonOptions = $jsonOptions | JSON_PRETTY_PRINT;
+            $jsonOptions |= JSON_PRETTY_PRINT;
         }
 
         return json_encode($data, $jsonOptions);