Completed
Push — master ( f04ca6...fcca9c )
by Jean
03:20 queued 01:30
created
src/FunctionCallTrait.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
      * @param mixed $value
26 26
      * @return array
27 27
      */
28
-    protected function prepareArgs (array $args, $value)
28
+    protected function prepareArgs(array $args, $value)
29 29
     {
30 30
         return $this->hasPlaceholder($args)
31 31
             ? $this->replacePlaceholderWithValue($args, $value)
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
      * @param array $args
38 38
      * @return bool
39 39
      */
40
-    protected function hasPlaceholder (array $args)
40
+    protected function hasPlaceholder(array $args)
41 41
     {
42 42
         return in_array($this->placeholder, $args, true);
43 43
     }
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
      * @param mixed $value
49 49
      * @return array
50 50
      */
51
-    protected function addValueAsFirstArg (array $args, $value)
51
+    protected function addValueAsFirstArg(array $args, $value)
52 52
     {
53 53
         array_unshift($args, $value);
54 54
 
@@ -61,9 +61,9 @@  discard block
 block discarded – undo
61 61
      * @param mixed $value
62 62
      * @return array
63 63
      */
64
-    protected function replacePlaceholderWithValue (array $args, $value)
64
+    protected function replacePlaceholderWithValue(array $args, $value)
65 65
     {
66
-        return array_map(function ($arg) use ($value) {
66
+        return array_map(function($arg) use ($value) {
67 67
             return $arg === $this->placeholder
68 68
                 ? $value
69 69
                 : $arg;
Please login to merge, or discard this patch.
src/Exceptions/BadTargetTypeException.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
      */
25 25
     public function __construct(DeferredCallChain $callchain, $expected_target, $target)
26 26
     {
27
-        $this->message = "You are trying to define a target of type ".gettype($target)." for the $callchain allowing only: ".$expected_target;
27
+        $this->message = "You are trying to define a target of type " . gettype($target) . " for the $callchain allowing only: " . $expected_target;
28 28
     }
29 29
     
30 30
     /**/
Please login to merge, or discard this patch.
src/Exceptions/TargetAlreadyDefinedException.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
      */
25 25
     public function __construct(DeferredCallChain $callchain, $expected_target, $target)
26 26
     {
27
-        $this->message = "You are trying to define the target ".spl_object_id($target)." for the $callchain which already has one: ".spl_object_id($expected_target);
27
+        $this->message = "You are trying to define the target " . spl_object_id($target) . " for the $callchain which already has one: " . spl_object_id($expected_target);
28 28
     }
29 29
     
30 30
     /**/
Please login to merge, or discard this patch.
src/Exceptions/UndefinedTargetClassException.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
      */
24 24
     public function __construct(DeferredCallChain $callchain, $expected_target)
25 25
     {
26
-        $this->message = "The expected target of $callchain is neither a existing class or interface nor a native type: ". $expected_target;
26
+        $this->message = "The expected target of $callchain is neither a existing class or interface nor a native type: " . $expected_target;
27 27
     }
28 28
     
29 29
     /**/
Please login to merge, or discard this patch.
src/Exceptions/BadTargetInterfaceException.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
      */
25 25
     public function __construct(DeferredCallChain $callchain, $expected_target, $target)
26 26
     {
27
-        $this->message = "You are trying to define a target of class ".get_class($target)." for the $callchain allowing only targets implementing ".$expected_target;
27
+        $this->message = "You are trying to define a target of class " . get_class($target) . " for the $callchain allowing only targets implementing " . $expected_target;
28 28
     }
29 29
     
30 30
     /**/
Please login to merge, or discard this patch.
src/Exceptions/BadTargetClassException.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
      */
25 25
     public function __construct(DeferredCallChain $callchain, $expected_target, $target)
26 26
     {
27
-        $this->message = "You are trying to define a target of class ".get_class($target)." for the $callchain allowing only targets of class ".$expected_target;
27
+        $this->message = "You are trying to define a target of class " . get_class($target) . " for the $callchain allowing only targets of class " . $expected_target;
28 28
     }
29 29
     
30 30
     /**/
Please login to merge, or discard this patch.
src/functions.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * File gathering functions
4 4
  */
5 5
 
6
-if (! function_exists('type_exists')) {
6
+if (!function_exists('type_exists')) {
7 7
     /**
8 8
      * Checks if a type is a valid PHP one.
9 9
      * 
@@ -27,14 +27,14 @@  discard block
 block discarded – undo
27 27
     }
28 28
 }
29 29
 
30
-if (! function_exists('later')) {
30
+if (!function_exists('later')) {
31 31
     /**
32 32
      * Create a deferred call chain in a functionnal way.
33 33
      * 
34 34
      * @param  string $class_type_interface_or_instance The expected target class/type/interface/instance
35 35
      * @return \JClaveau\Async\DeferredCallChain
36 36
      */
37
-    function later($class_type_interface_or_instance=null)
37
+    function later($class_type_interface_or_instance = null)
38 38
     {
39 39
         return new \JClaveau\Async\DeferredCallChain(...func_get_args());
40 40
     }
Please login to merge, or discard this patch.
src/ExportTrait.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
      *
41 41
      * @return string The PHP code corresponding to this call chain
42 42
      */
43
-    public function toString(array $options=[])
43
+    public function toString(array $options = [])
44 44
     {
45 45
         $target = isset($options['target']) ? $options['target'] : $this->expectedTarget;
46 46
         $max_param_length = isset($options['max_parameter_length']) ? $options['max_parameter_length'] : 56;
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
         foreach ($this->stack as $i => $call) {
57 57
             if (isset($call['method'])) {
58 58
                 $string .= '->';
59
-                $string .= $call['method'].'(';
59
+                $string .= $call['method'] . '(';
60 60
                 $string .= implode(', ', array_map(function($argument) use ($max_param_length, $short_objects) {
61 61
                     return static::varExport($argument, [
62 62
                         'short_objects' => $short_objects, 
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
                 ]) . ']';
73 73
             }
74 74
             
75
-            if (! empty($options['limit']) && $options['limit'] == $i) {
75
+            if (!empty($options['limit']) && $options['limit'] == $i) {
76 76
                 break;
77 77
             }
78 78
         }
@@ -87,10 +87,10 @@  discard block
 block discarded – undo
87 87
      * @param  array  $options max_length | alias_instances
88 88
      * @return string The PHP code of the variable
89 89
      */
90
-    protected static function varExport($variable, array $options=[])
90
+    protected static function varExport($variable, array $options = [])
91 91
     {
92 92
         $options['max_length']    = isset($options['max_length']) ? $options['max_length'] : 56;
93
-        $options['short_objects'] = (! empty($options['short_objects'])) || in_array('short_objects', $options);
93
+        $options['short_objects'] = (!empty($options['short_objects'])) || in_array('short_objects', $options);
94 94
         
95 95
         $export = var_export($variable, true);
96 96
         
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -64,8 +64,7 @@  discard block
 block discarded – undo
64 64
                     ]);
65 65
                 }, $call['arguments']));
66 66
                 $string .= ')';
67
-            }
68
-            else {
67
+            } else {
69 68
                 $string .= '[' . static::varExport($call['entry'], [
70 69
                     'short_objects' => $short_objects, 
71 70
                     'max_length' => $max_param_length,
@@ -105,8 +104,7 @@  discard block
 block discarded – undo
105 104
             if (is_object($variable)) {
106 105
                 // shortening short objects would only slow the workflow
107 106
                 $export = get_class($variable) . ' #' . spl_object_id($variable);
108
-            }
109
-            elseif (is_string($variable)) {
107
+            } elseif (is_string($variable)) {
110 108
                 $keep_length = floor(($options['max_length'] - 5) / 2);
111 109
                 
112 110
                 $export = substr($variable, 0, (int) $keep_length)
Please login to merge, or discard this patch.
src/DeferredCallChain.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
      * 
37 37
      * @param string $class_type_interface_or_instance The expected target class/type/interface/instance
38 38
      */
39
-    public function __construct($class_type_interface_or_instance=null)
39
+    public function __construct($class_type_interface_or_instance = null)
40 40
     {
41 41
         if ($class_type_interface_or_instance) {
42 42
             $this->expectedTarget = $class_type_interface_or_instance;
@@ -101,12 +101,12 @@  discard block
 block discarded – undo
101 101
         }
102 102
         elseif (is_string($this->expectedTarget)) {
103 103
             if (class_exists($this->expectedTarget)) {
104
-                if (! $target instanceof $this->expectedTarget) {
104
+                if (!$target instanceof $this->expectedTarget) {
105 105
                     throw new BadTargetClassException($this, $this->expectedTarget, $target);
106 106
                 }
107 107
             }
108 108
             elseif (interface_exists($this->expectedTarget)) {
109
-                if (! $target instanceof $this->expectedTarget) {
109
+                if (!$target instanceof $this->expectedTarget) {
110 110
                     throw new BadTargetInterfaceException($this, $this->expectedTarget, $target);
111 111
                 }
112 112
             }
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
                     $class = $current_chained_subject;
158 158
                 }
159 159
                 
160
-                $callable = $class .'::'. $method_name;
160
+                $callable = $class . '::' . $method_name;
161 161
             }
162 162
             
163 163
             $current_chained_subject = call_user_func_array(
@@ -202,8 +202,8 @@  discard block
 block discarded – undo
202 202
         
203 203
         return  
204 204
                 ($trace[0]['function'] == '__call' || $trace[0]['function'] == '__callStatic')
205
-            &&  $trace[0]['class']    == get_class($current_chained_subject)
206
-            &&  $trace[0]['args'][0]  == $method_name
205
+            &&  $trace[0]['class'] == get_class($current_chained_subject)
206
+            &&  $trace[0]['args'][0] == $method_name
207 207
             && (
208 208
                     $trace[$call_user_func_array_position]['file'] == __FILE__
209 209
                 &&  $trace[$call_user_func_array_position]['function'] == 'call_user_func_array'
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
      * @param  mixed $target The target to apply the callchain on
218 218
      * @return mixed The value returned once the call chain is called uppon $target
219 219
      */
220
-    public function __invoke($target=null)
220
+    public function __invoke($target = null)
221 221
     {
222 222
         $out = $this->checkTarget($target);
223 223
         
@@ -234,9 +234,9 @@  discard block
 block discarded – undo
234 234
                         );
235 235
                     }
236 236
                     
237
-                    if (! $is_called && (
238
-                                (is_string($out) && is_callable($out .'::'.$call['method']))
239
-                            ||  (is_object($out) && is_callable(get_class($out) .'::'.$call['method']))
237
+                    if (!$is_called && (
238
+                                (is_string($out) && is_callable($out . '::' . $call['method']))
239
+                            ||  (is_object($out) && is_callable(get_class($out) . '::' . $call['method']))
240 240
                         )
241 241
                     ) {
242 242
                         $is_called = $this->checkMethodIsReallyCallable(
@@ -247,13 +247,13 @@  discard block
 block discarded – undo
247 247
                         );
248 248
                     }
249 249
                     
250
-                    if (! $is_called && is_callable($call['method'])) {
250
+                    if (!$is_called && is_callable($call['method'])) {
251 251
                         $arguments = $this->prepareArgs($call['arguments'], $out);
252 252
                         $out = call_user_func_array($call['method'], $arguments);
253 253
                         $is_called = true;
254 254
                     }
255 255
                     
256
-                    if (! $is_called) {
256
+                    if (!$is_called) {
257 257
                         throw new \BadMethodCallException(
258 258
                             $call['method'] . "() is neither a method of " . get_class($out)
259 259
                             . " nor a function"
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
                     }
262 262
                 }
263 263
                 else {
264
-                    $out = $out[ $call['entry'] ];
264
+                    $out = $out[$call['entry']];
265 265
                 }
266 266
             }
267 267
             catch (\Exception $e) {
Please login to merge, or discard this patch.
Braces   +11 added lines, -22 removed lines patch added patch discarded remove patch
@@ -98,30 +98,25 @@  discard block
 block discarded – undo
98 98
             }
99 99
             
100 100
             $out = $this->expectedTarget;
101
-        }
102
-        elseif (is_string($this->expectedTarget)) {
101
+        } elseif (is_string($this->expectedTarget)) {
103 102
             if (class_exists($this->expectedTarget)) {
104 103
                 if (! $target instanceof $this->expectedTarget) {
105 104
                     throw new BadTargetClassException($this, $this->expectedTarget, $target);
106 105
                 }
107
-            }
108
-            elseif (interface_exists($this->expectedTarget)) {
106
+            } elseif (interface_exists($this->expectedTarget)) {
109 107
                 if (! $target instanceof $this->expectedTarget) {
110 108
                     throw new BadTargetInterfaceException($this, $this->expectedTarget, $target);
111 109
                 }
112
-            }
113
-            elseif (type_exists($this->expectedTarget)) {
110
+            } elseif (type_exists($this->expectedTarget)) {
114 111
                 if (gettype($target) != $this->expectedTarget) {
115 112
                     throw new BadTargetTypeException($this, $this->expectedTarget, $target);
116 113
                 }
117
-            }
118
-            else {
114
+            } else {
119 115
                 throw new UndefinedTargetClassException($this, $this->expectedTarget);
120 116
             }
121 117
             
122 118
             $out = $target;
123
-        }
124
-        else {
119
+        } else {
125 120
             $out = $target;
126 121
         }
127 122
         
@@ -148,12 +143,10 @@  discard block
 block discarded – undo
148 143
         try {
149 144
             if ($method_type == '->') {
150 145
                 $callable = [$current_chained_subject, $method_name];
151
-            }
152
-            elseif ($method_type == '::') {
146
+            } elseif ($method_type == '::') {
153 147
                 if (is_object($current_chained_subject)) {
154 148
                     $class = get_class($current_chained_subject);
155
-                }
156
-                elseif (is_string($current_chained_subject)) {
149
+                } elseif (is_string($current_chained_subject)) {
157 150
                     $class = $current_chained_subject;
158 151
                 }
159 152
                 
@@ -164,16 +157,14 @@  discard block
 block discarded – undo
164 157
                 $callable, 
165 158
                 $arguments
166 159
             );
167
-        }
168
-        catch (\BadMethodCallException $e) {
160
+        } catch (\BadMethodCallException $e) {
169 161
             if ($this->exceptionTrownFromMagicCall(
170 162
                 $e->getTrace(),
171 163
                 $current_chained_subject,
172 164
                 $method_name
173 165
             )) {
174 166
                 $is_called = false;
175
-            }
176
-            else {
167
+            } else {
177 168
                 throw $e;
178 169
             }
179 170
         }
@@ -259,12 +250,10 @@  discard block
 block discarded – undo
259 250
                             . " nor a function"
260 251
                         );
261 252
                     }
262
-                }
263
-                else {
253
+                } else {
264 254
                     $out = $out[ $call['entry'] ];
265 255
                 }
266
-            }
267
-            catch (\Exception $e) {
256
+            } catch (\Exception $e) {
268 257
                 
269 258
                 $callchain_description = $this->toString([
270 259
                     'target' => $target,
Please login to merge, or discard this patch.