Completed
Push — master ( a9a146...85a956 )
by Jean
02:11
created
src/DeferredCallChain.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -185,7 +185,7 @@
 block discarded – undo
185 185
                             // can produce a BadMethodCallException and thus
186 186
                             // not be a callable
187 187
                             if (
188
-                                   $e->getTrace()[2]['file'] == __FILE__
188
+                                    $e->getTrace()[2]['file'] == __FILE__
189 189
                                 && $e->getTrace()[2]['function'] == 'call_user_func_array'
190 190
                                 && $e->getTrace()[1]['function'] == $call['method']
191 191
                                 && $e->getTrace()[1]['class'] == get_class($out)
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
      * 
34 34
      * @param string $key The entry to acces
35 35
      */
36
-    public function __construct($class_type_or_instance=null)
36
+    public function __construct($class_type_or_instance = null)
37 37
     {
38 38
         if ($class_type_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
             }
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
      * @param  $target The target to apply the callchain on
168 168
      * @return The value returned once the call chain is called uppon $target
169 169
      */
170
-    public function __invoke($target=null)
170
+    public function __invoke($target = null)
171 171
     {
172 172
         $out = $this->checkTarget($target);
173 173
         
@@ -200,14 +200,14 @@  discard block
 block discarded – undo
200 200
                         }
201 201
                     }
202 202
                     
203
-                    if (! $is_called && is_callable($call['method'])) {
203
+                    if (!$is_called && is_callable($call['method'])) {
204 204
                         $arguments = $this->prepareArgs($call['arguments'], $out);
205 205
                         
206 206
                         $out = call_user_func_array($call['method'], $arguments);
207 207
                         $is_called = true;
208 208
                     }
209 209
                     
210
-                    if (! $is_called) {
210
+                    if (!$is_called) {
211 211
                         throw new \BadMethodCallException(
212 212
                             $call['method'] . "() is neither a method of " . get_class($out)
213 213
                             . " nor a function"
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
                     }
216 216
                 }
217 217
                 else {
218
-                    $out = $out[ $call['entry'] ];
218
+                    $out = $out[$call['entry']];
219 219
                 }
220 220
             }
221 221
             catch (\Exception $e) {
Please login to merge, or discard this patch.
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
         
@@ -179,8 +172,7 @@  discard block
 block discarded – undo
179 172
                         $is_called = true;
180 173
                         try {
181 174
                             $out = call_user_func_array([$out, $call['method']], $call['arguments']);
182
-                        }
183
-                        catch (\BadMethodCallException $e) {
175
+                        } catch (\BadMethodCallException $e) {
184 176
                             // Calling a method coded inside a magic __call
185 177
                             // can produce a BadMethodCallException and thus
186 178
                             // not be a callable
@@ -193,8 +185,7 @@  discard block
 block discarded – undo
193 185
                                 && $e->getTrace()[0]['class'] == get_class($out)
194 186
                             ) {
195 187
                                 $is_called = false;
196
-                            }
197
-                            else {
188
+                            } else {
198 189
                                 throw $e;
199 190
                             }
200 191
                         }
@@ -213,12 +204,10 @@  discard block
 block discarded – undo
213 204
                             . " nor a function"
214 205
                         );
215 206
                     }
216
-                }
217
-                else {
207
+                } else {
218 208
                     $out = $out[ $call['entry'] ];
219 209
                 }
220
-            }
221
-            catch (\Exception $e) {
210
+            } catch (\Exception $e) {
222 211
                 // Throw $e with the good stack (usage exception)
223 212
                 throw $e;
224 213
             }
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
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
      * @return array
24 24
      */
25 25
     // protected function prepareArgs (array $args) : array
26
-    protected function prepareArgs (array $args, $value)
26
+    protected function prepareArgs(array $args, $value)
27 27
     {
28 28
         return $this->hasPlaceholder($args)
29 29
             ? $this->replacePlaceholderWithValue($args, $value)
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
      * @return bool
37 37
      */
38 38
     // protected function hasPlaceholder (array $args) : bool
39
-    protected function hasPlaceholder (array $args)
39
+    protected function hasPlaceholder(array $args)
40 40
     {
41 41
         return in_array($this->placeholder, $args, true);
42 42
     }
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
      * @return array
48 48
      */
49 49
     // protected function addValueAsFirstArg (array $args) : array
50
-    protected function addValueAsFirstArg (array $args, $value)
50
+    protected function addValueAsFirstArg(array $args, $value)
51 51
     {
52 52
         array_unshift($args, $value);
53 53
 
@@ -60,10 +60,10 @@  discard block
 block discarded – undo
60 60
      * @param mixed $value
61 61
      * @return array
62 62
      */
63
-    protected function replacePlaceholderWithValue (array $args, $value)
63
+    protected function replacePlaceholderWithValue(array $args, $value)
64 64
     // protected function replacePlaceholderWithValue (array $args) : array
65 65
     {
66
-        return array_map([$this, function ($arg) use ($value) {
66
+        return array_map([$this, function($arg) use ($value) {
67 67
             return $arg === $this->placeholder
68 68
                 ? $value
69 69
                 : $arg;
Please login to merge, or discard this patch.