@@ -24,6 +24,6 @@ |
||
24 | 24 | */ |
25 | 25 | public function __construct(DeferredCallChain $callchain, $expected_target) |
26 | 26 | { |
27 | - $this->message = "The expected target of {$callchain} is neither a existing class or interface nor a native type: " . $expected_target; |
|
27 | + $this->message = "The expected target of {$callchain} is neither a existing class or interface nor a native type: ".$expected_target; |
|
28 | 28 | } |
29 | 29 | } |
30 | 30 | \ No newline at end of file |
@@ -25,6 +25,6 @@ |
||
25 | 25 | */ |
26 | 26 | public function __construct(DeferredCallChain $callchain, $expected_target, $target) |
27 | 27 | { |
28 | - $this->message = "You are trying to define a target of class " . get_class($target) . " for the {$callchain} allowing only targets implementing " . $expected_target; |
|
28 | + $this->message = "You are trying to define a target of class ".get_class($target)." for the {$callchain} allowing only targets implementing ".$expected_target; |
|
29 | 29 | } |
30 | 30 | } |
31 | 31 | \ No newline at end of file |
@@ -81,11 +81,11 @@ discard block |
||
81 | 81 | $out = $this->expectedTarget; |
82 | 82 | } elseif (is_string($this->expectedTarget)) { |
83 | 83 | if (class_exists($this->expectedTarget)) { |
84 | - if (!$target instanceof $this->expectedTarget) { |
|
84 | + if ( ! $target instanceof $this->expectedTarget) { |
|
85 | 85 | throw new BadTargetClassException($this, $this->expectedTarget, $target); |
86 | 86 | } |
87 | 87 | } elseif (interface_exists($this->expectedTarget)) { |
88 | - if (!$target instanceof $this->expectedTarget) { |
|
88 | + if ( ! $target instanceof $this->expectedTarget) { |
|
89 | 89 | throw new BadTargetInterfaceException($this, $this->expectedTarget, $target); |
90 | 90 | } |
91 | 91 | } elseif (type_exists($this->expectedTarget)) { |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | } elseif (is_string($current_chained_subject)) { |
125 | 125 | $class = $current_chained_subject; |
126 | 126 | } |
127 | - $callable = $class . '::' . $method_name; |
|
127 | + $callable = $class.'::'.$method_name; |
|
128 | 128 | } |
129 | 129 | $current_chained_subject = call_user_func_array($callable, $arguments); |
130 | 130 | } catch (\BadMethodCallException $e) { |
@@ -169,23 +169,23 @@ discard block |
||
169 | 169 | if (is_callable([$out, $call['method']])) { |
170 | 170 | $is_called = $this->checkMethodIsReallyCallable('->', $out, $call['method'], $call['arguments']); |
171 | 171 | } |
172 | - if (!$is_called && (is_string($out) && is_callable($out . '::' . $call['method']) || is_object($out) && is_callable(get_class($out) . '::' . $call['method']))) { |
|
172 | + if ( ! $is_called && (is_string($out) && is_callable($out.'::'.$call['method']) || is_object($out) && is_callable(get_class($out).'::'.$call['method']))) { |
|
173 | 173 | $is_called = $this->checkMethodIsReallyCallable('::', $out, $call['method'], $call['arguments']); |
174 | 174 | } |
175 | - if (!$is_called && is_callable($call['method'])) { |
|
175 | + if ( ! $is_called && is_callable($call['method'])) { |
|
176 | 176 | $arguments = $this->prepareArgs($call['arguments'], $out); |
177 | 177 | $out = call_user_func_array($call['method'], $arguments); |
178 | 178 | $is_called = true; |
179 | 179 | } |
180 | - if (!$is_called) { |
|
181 | - throw new \BadMethodCallException($call['method'] . "() is neither a method of " . get_class($out) . " nor a function"); |
|
180 | + if ( ! $is_called) { |
|
181 | + throw new \BadMethodCallException($call['method']."() is neither a method of ".get_class($out)." nor a function"); |
|
182 | 182 | } |
183 | 183 | } else { |
184 | 184 | $out = $out[$call['entry']]; |
185 | 185 | } |
186 | 186 | } catch (\Exception $e) { |
187 | 187 | $callchain_description = $this->toString(['target' => $target, 'limit' => $i]); |
188 | - VisibilityViolator::setHiddenProperty($e, 'message', $e->getMessage() . "\nWhen applying {$callchain_description} defined at " . $call['file'] . ':' . $call['line']); |
|
188 | + VisibilityViolator::setHiddenProperty($e, 'message', $e->getMessage()."\nWhen applying {$callchain_description} defined at ".$call['file'].':'.$call['line']); |
|
189 | 189 | // Throw $e with the good stack (usage exception) |
190 | 190 | throw $e; |
191 | 191 | } |
@@ -79,24 +79,29 @@ discard block |
||
79 | 79 | throw new TargetAlreadyDefinedException($this, $this->expectedTarget, $target); |
80 | 80 | } |
81 | 81 | $out = $this->expectedTarget; |
82 | - } elseif (is_string($this->expectedTarget)) { |
|
82 | + } |
|
83 | + elseif (is_string($this->expectedTarget)) { |
|
83 | 84 | if (class_exists($this->expectedTarget)) { |
84 | 85 | if (!$target instanceof $this->expectedTarget) { |
85 | 86 | throw new BadTargetClassException($this, $this->expectedTarget, $target); |
86 | 87 | } |
87 | - } elseif (interface_exists($this->expectedTarget)) { |
|
88 | + } |
|
89 | + elseif (interface_exists($this->expectedTarget)) { |
|
88 | 90 | if (!$target instanceof $this->expectedTarget) { |
89 | 91 | throw new BadTargetInterfaceException($this, $this->expectedTarget, $target); |
90 | 92 | } |
91 | - } elseif (type_exists($this->expectedTarget)) { |
|
93 | + } |
|
94 | + elseif (type_exists($this->expectedTarget)) { |
|
92 | 95 | if (gettype($target) != $this->expectedTarget) { |
93 | 96 | throw new BadTargetTypeException($this, $this->expectedTarget, $target); |
94 | 97 | } |
95 | - } else { |
|
98 | + } |
|
99 | + else { |
|
96 | 100 | throw new UndefinedTargetClassException($this, $this->expectedTarget); |
97 | 101 | } |
98 | 102 | $out = $target; |
99 | - } else { |
|
103 | + } |
|
104 | + else { |
|
100 | 105 | $out = $target; |
101 | 106 | } |
102 | 107 | return $out; |
@@ -118,19 +123,23 @@ discard block |
||
118 | 123 | try { |
119 | 124 | if ($method_type == '->') { |
120 | 125 | $callable = [$current_chained_subject, $method_name]; |
121 | - } elseif ($method_type == '::') { |
|
126 | + } |
|
127 | + elseif ($method_type == '::') { |
|
122 | 128 | if (is_object($current_chained_subject)) { |
123 | 129 | $class = get_class($current_chained_subject); |
124 | - } elseif (is_string($current_chained_subject)) { |
|
130 | + } |
|
131 | + elseif (is_string($current_chained_subject)) { |
|
125 | 132 | $class = $current_chained_subject; |
126 | 133 | } |
127 | 134 | $callable = $class . '::' . $method_name; |
128 | 135 | } |
129 | 136 | $current_chained_subject = call_user_func_array($callable, $arguments); |
130 | - } catch (\BadMethodCallException $e) { |
|
137 | + } |
|
138 | + catch (\BadMethodCallException $e) { |
|
131 | 139 | if ($this->exceptionTrownFromMagicCall($e->getTrace(), $current_chained_subject, $method_name)) { |
132 | 140 | $is_called = false; |
133 | - } else { |
|
141 | + } |
|
142 | + else { |
|
134 | 143 | throw $e; |
135 | 144 | } |
136 | 145 | } |
@@ -180,10 +189,12 @@ discard block |
||
180 | 189 | if (!$is_called) { |
181 | 190 | throw new \BadMethodCallException($call['method'] . "() is neither a method of " . get_class($out) . " nor a function"); |
182 | 191 | } |
183 | - } else { |
|
192 | + } |
|
193 | + else { |
|
184 | 194 | $out = $out[$call['entry']]; |
185 | 195 | } |
186 | - } catch (\Exception $e) { |
|
196 | + } |
|
197 | + catch (\Exception $e) { |
|
187 | 198 | $callchain_description = $this->toString(['target' => $target, 'limit' => $i]); |
188 | 199 | VisibilityViolator::setHiddenProperty($e, 'message', $e->getMessage() . "\nWhen applying {$callchain_description} defined at " . $call['file'] . ':' . $call['line']); |
189 | 200 | // Throw $e with the good stack (usage exception) |
@@ -45,21 +45,21 @@ discard block |
||
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; |
47 | 47 | $short_objects = isset($options['short_objects']) ? $options['short_objects'] : true; |
48 | - $string = '(new ' . get_called_class(); |
|
49 | - $target && ($string .= '(' . static::varExport($target, ['short_objects' => $short_objects, 'max_length' => $max_param_length]) . ')'); |
|
48 | + $string = '(new '.get_called_class(); |
|
49 | + $target && ($string .= '('.static::varExport($target, ['short_objects' => $short_objects, 'max_length' => $max_param_length]).')'); |
|
50 | 50 | $string .= ')'; |
51 | 51 | foreach ($this->stack as $i => $call) { |
52 | 52 | if (isset($call['method'])) { |
53 | 53 | $string .= '->'; |
54 | - $string .= $call['method'] . '('; |
|
55 | - $string .= implode(', ', array_map(function ($argument) use($max_param_length, $short_objects) { |
|
54 | + $string .= $call['method'].'('; |
|
55 | + $string .= implode(', ', array_map(function($argument) use($max_param_length, $short_objects) { |
|
56 | 56 | return static::varExport($argument, ['short_objects' => $short_objects, 'max_length' => $max_param_length]); |
57 | 57 | }, $call['arguments'])); |
58 | 58 | $string .= ')'; |
59 | 59 | } else { |
60 | - $string .= '[' . static::varExport($call['entry'], ['short_objects' => $short_objects, 'max_length' => $max_param_length]) . ']'; |
|
60 | + $string .= '['.static::varExport($call['entry'], ['short_objects' => $short_objects, 'max_length' => $max_param_length]).']'; |
|
61 | 61 | } |
62 | - if (!empty($options['limit']) && $options['limit'] == $i) { |
|
62 | + if ( ! empty($options['limit']) && $options['limit'] == $i) { |
|
63 | 63 | break; |
64 | 64 | } |
65 | 65 | } |
@@ -75,20 +75,20 @@ discard block |
||
75 | 75 | protected static function varExport($variable, array $options = []) |
76 | 76 | { |
77 | 77 | $options['max_length'] = isset($options['max_length']) ? $options['max_length'] : 56; |
78 | - $options['short_objects'] = !empty($options['short_objects']) || in_array('short_objects', $options); |
|
78 | + $options['short_objects'] = ! empty($options['short_objects']) || in_array('short_objects', $options); |
|
79 | 79 | $export = var_export($variable, true); |
80 | 80 | if ($options['short_objects']) { |
81 | 81 | if (is_object($variable)) { |
82 | - $export = ' ' . get_class($variable) . ' #' . spl_object_id($variable) . ' '; |
|
82 | + $export = ' '.get_class($variable).' #'.spl_object_id($variable).' '; |
|
83 | 83 | } |
84 | 84 | } |
85 | 85 | if (strlen($export) > $options['max_length']) { |
86 | 86 | if (is_object($variable)) { |
87 | 87 | // shortening short objects would only slow the workflow |
88 | - $export = get_class($variable) . ' #' . spl_object_id($variable); |
|
88 | + $export = get_class($variable).' #'.spl_object_id($variable); |
|
89 | 89 | } elseif (is_string($variable)) { |
90 | 90 | $keep_length = floor(($options['max_length'] - 5) / 2); |
91 | - $export = substr($variable, 0, (int) $keep_length) . ' ... ' . substr($variable, -$keep_length); |
|
91 | + $export = substr($variable, 0, (int) $keep_length).' ... '.substr($variable, -$keep_length); |
|
92 | 92 | } |
93 | 93 | } |
94 | 94 | return $export; |
@@ -56,7 +56,8 @@ discard block |
||
56 | 56 | return static::varExport($argument, ['short_objects' => $short_objects, 'max_length' => $max_param_length]); |
57 | 57 | }, $call['arguments'])); |
58 | 58 | $string .= ')'; |
59 | - } else { |
|
59 | + } |
|
60 | + else { |
|
60 | 61 | $string .= '[' . static::varExport($call['entry'], ['short_objects' => $short_objects, 'max_length' => $max_param_length]) . ']'; |
61 | 62 | } |
62 | 63 | if (!empty($options['limit']) && $options['limit'] == $i) { |
@@ -86,7 +87,8 @@ discard block |
||
86 | 87 | if (is_object($variable)) { |
87 | 88 | // shortening short objects would only slow the workflow |
88 | 89 | $export = get_class($variable) . ' #' . spl_object_id($variable); |
89 | - } elseif (is_string($variable)) { |
|
90 | + } |
|
91 | + elseif (is_string($variable)) { |
|
90 | 92 | $keep_length = floor(($options['max_length'] - 5) / 2); |
91 | 93 | $export = substr($variable, 0, (int) $keep_length) . ' ... ' . substr($variable, -$keep_length); |
92 | 94 | } |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | /** |
4 | 4 | * File gathering functions |
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 | * |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | return in_array($type_name, ["boolean", "integer", "double", "string", "array", "object", "resource", "resource (closed)", "NULL", "unknown type"]); |
16 | 16 | } |
17 | 17 | } |
18 | -if (!function_exists('later')) { |
|
18 | +if ( ! function_exists('later')) { |
|
19 | 19 | /** |
20 | 20 | * Create a deferred call chain in a functionnal way. |
21 | 21 | * |