Test Failed
Push — master ( eabe42...d0d467 )
by Jean
02:13
created
src/DeferredCallChain.php 2 patches
Braces   +11 added lines, -22 removed lines patch added patch discarded remove patch
@@ -93,8 +93,7 @@  discard block
 block discarded – undo
93 93
         $string = '(new ' . get_called_class();
94 94
         if (is_string($this->expectedTarget)) {
95 95
             $string .= '(' . var_export($this->expectedTarget, true) . ')';
96
-        }
97
-        elseif (is_object($this->expectedTarget)) {
96
+        } elseif (is_object($this->expectedTarget)) {
98 97
             $string .= '( ' . get_class($this->expectedTarget) . '#' . spl_object_id($this->expectedTarget) . ' )';
99 98
         }
100 99
         $string .= ')';
@@ -107,8 +106,7 @@  discard block
 block discarded – undo
107 106
                     return var_export($argument, true);
108 107
                 }, $call['arguments']));
109 108
                 $string .= ')';
110
-            }
111
-            else {
109
+            } else {
112 110
                 $string .= '[' . var_export($call['entry'], true) . ']';
113 111
             }
114 112
         }
@@ -131,30 +129,25 @@  discard block
 block discarded – undo
131 129
             }
132 130
             
133 131
             $out = $this->expectedTarget;
134
-        }
135
-        elseif (is_string($this->expectedTarget)) {
132
+        } elseif (is_string($this->expectedTarget)) {
136 133
             if (class_exists($this->expectedTarget)) {
137 134
                 if (! $target instanceof $this->expectedTarget) {
138 135
                     throw new BadTargetClassException($this, $this->expectedTarget, $target);
139 136
                 }
140
-            }
141
-            elseif (interface_exists($this->expectedTarget)) {
137
+            } elseif (interface_exists($this->expectedTarget)) {
142 138
                 if (! $target instanceof $this->expectedTarget) {
143 139
                     throw new BadTargetInterfaceException($this, $this->expectedTarget, $target);
144 140
                 }
145
-            }
146
-            elseif (type_exists($this->expectedTarget)) {
141
+            } elseif (type_exists($this->expectedTarget)) {
147 142
                 if (gettype($target) != $this->expectedTarget) {
148 143
                     throw new BadTargetTypeException($this, $this->expectedTarget, $target);
149 144
                 }
150
-            }
151
-            else {
145
+            } else {
152 146
                 throw new UndefinedTargetClassException($this, $this->expectedTarget);
153 147
             }
154 148
             
155 149
             $out = $target;
156
-        }
157
-        else {
150
+        } else {
158 151
             $out = $target;
159 152
         }
160 153
         
@@ -182,16 +175,14 @@  discard block
 block discarded – undo
182 175
                 [$current_chained_subject, $method_name], 
183 176
                 $arguments
184 177
             );
185
-        }
186
-        catch (\BadMethodCallException $e) {
178
+        } catch (\BadMethodCallException $e) {
187 179
             if ($this->exceptionTrownFromMagicCall(
188 180
                 $e->getTrace(),
189 181
                 $current_chained_subject,
190 182
                 $method_name
191 183
             )) {
192 184
                 $is_called = false;
193
-            }
194
-            else {
185
+            } else {
195 186
                 throw $e;
196 187
             }
197 188
         }
@@ -261,12 +252,10 @@  discard block
 block discarded – undo
261 252
                             . " nor a function"
262 253
                         );
263 254
                     }
264
-                }
265
-                else {
255
+                } else {
266 256
                     $out = $out[ $call['entry'] ];
267 257
                 }
268
-            }
269
-            catch (\Exception $e) {
258
+            } catch (\Exception $e) {
270 259
                 // Throw $e with the good stack (usage exception)
271 260
                 throw $e;
272 261
             }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
      * 
34 34
      * @param string $class_type_interface_or_instance The expected target class/type/interface/instance
35 35
      */
36
-    public function __construct($class_type_interface_or_instance=null)
36
+    public function __construct($class_type_interface_or_instance = null)
37 37
     {
38 38
         if ($class_type_interface_or_instance) {
39 39
             $this->expectedTarget = $class_type_or_instance;
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
         foreach ($this->stack as $i => $call) {
103 103
             if (isset($call['method'])) {
104 104
                 $string .= '->';
105
-                $string .= $call['method'].'(';
105
+                $string .= $call['method'] . '(';
106 106
                 $string .= implode(', ', array_map(function($argument) {
107 107
                     return var_export($argument, true);
108 108
                 }, $call['arguments']));
@@ -134,12 +134,12 @@  discard block
 block discarded – undo
134 134
         }
135 135
         elseif (is_string($this->expectedTarget)) {
136 136
             if (class_exists($this->expectedTarget)) {
137
-                if (! $target instanceof $this->expectedTarget) {
137
+                if (!$target instanceof $this->expectedTarget) {
138 138
                     throw new BadTargetClassException($this, $this->expectedTarget, $target);
139 139
                 }
140 140
             }
141 141
             elseif (interface_exists($this->expectedTarget)) {
142
-                if (! $target instanceof $this->expectedTarget) {
142
+                if (!$target instanceof $this->expectedTarget) {
143 143
                     throw new BadTargetInterfaceException($this, $this->expectedTarget, $target);
144 144
                 }
145 145
             }
@@ -220,8 +220,8 @@  discard block
 block discarded – undo
220 220
         
221 221
         return  
222 222
                 $trace[0]['function'] == '__call'
223
-            &&  $trace[0]['class']    == get_class($current_chained_subject)
224
-            &&  $trace[0]['args'][0]  == $method_name
223
+            &&  $trace[0]['class'] == get_class($current_chained_subject)
224
+            &&  $trace[0]['args'][0] == $method_name
225 225
             && (
226 226
                     $trace[$call_user_func_array_position]['file'] == __FILE__
227 227
                 &&  $trace[$call_user_func_array_position]['function'] == 'call_user_func_array'
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
      * @param  mixed $target The target to apply the callchain on
236 236
      * @return mixed The value returned once the call chain is called uppon $target
237 237
      */
238
-    public function __invoke($target=null)
238
+    public function __invoke($target = null)
239 239
     {
240 240
         $out = $this->checkTarget($target);
241 241
         
@@ -251,13 +251,13 @@  discard block
 block discarded – undo
251 251
                         );
252 252
                     }
253 253
                     
254
-                    if (! $is_called && is_callable($call['method'])) {
254
+                    if (!$is_called && is_callable($call['method'])) {
255 255
                         $arguments = $this->prepareArgs($call['arguments'], $out);
256 256
                         $out = call_user_func_array($call['method'], $arguments);
257 257
                         $is_called = true;
258 258
                     }
259 259
                     
260
-                    if (! $is_called) {
260
+                    if (!$is_called) {
261 261
                         throw new \BadMethodCallException(
262 262
                             $call['method'] . "() is neither a method of " . get_class($out)
263 263
                             . " nor a function"
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
                     }
266 266
                 }
267 267
                 else {
268
-                    $out = $out[ $call['entry'] ];
268
+                    $out = $out[$call['entry']];
269 269
                 }
270 270
             }
271 271
             catch (\Exception $e) {
Please login to merge, or discard this patch.
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.