@@ -25,7 +25,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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; |
@@ -37,16 +37,16 @@ |
||
37 | 37 | * the code needing it. |
38 | 38 | */ |
39 | 39 | $sorted_map = [ |
40 | - 'ArrayAccessTrait.php', |
|
41 | - 'FunctionCallTrait.php', |
|
42 | - 'ExportTrait.php', |
|
43 | - 'DeferredCallChain.php', |
|
44 | - 'Exceptions/BadTargetClassException.php', |
|
45 | - 'Exceptions/BadTargetInterfaceException.php', |
|
46 | - 'Exceptions/BadTargetTypeException.php', |
|
47 | - 'Exceptions/TargetAlreadyDefinedException.php', |
|
48 | - 'Exceptions/UndefinedTargetClassException.php', |
|
49 | - 'functions.php', |
|
40 | + 'ArrayAccessTrait.php', |
|
41 | + 'FunctionCallTrait.php', |
|
42 | + 'ExportTrait.php', |
|
43 | + 'DeferredCallChain.php', |
|
44 | + 'Exceptions/BadTargetClassException.php', |
|
45 | + 'Exceptions/BadTargetInterfaceException.php', |
|
46 | + 'Exceptions/BadTargetTypeException.php', |
|
47 | + 'Exceptions/TargetAlreadyDefinedException.php', |
|
48 | + 'Exceptions/UndefinedTargetClassException.php', |
|
49 | + 'functions.php', |
|
50 | 50 | ]; |
51 | 51 | |
52 | 52 | if ($missing = array_diff($sorted_map, $map)) { |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | */ |
4 | 4 | function scandir_r($directory) { |
5 | 5 | // $files = array_slice(scandir($directory, SCANDIR_SORT_NONE), 2); |
6 | - if (! $entries = scandir($directory)) { |
|
6 | + if ( ! $entries = scandir($directory)) { |
|
7 | 7 | throw new \InvalidArgumentException("Error during scandir"); |
8 | 8 | } |
9 | 9 | |
@@ -11,12 +11,12 @@ discard block |
||
11 | 11 | |
12 | 12 | $map = []; |
13 | 13 | foreach ($files as $file) { |
14 | - if (is_dir( $directory . '/' . $file)) { |
|
15 | - $submap = scandir_r($directory . '/' . $file); |
|
14 | + if (is_dir($directory.'/'.$file)) { |
|
15 | + $submap = scandir_r($directory.'/'.$file); |
|
16 | 16 | $map = array_merge($map, $submap); |
17 | 17 | } |
18 | 18 | else { |
19 | - $map[] = $directory . '/' . $file; |
|
19 | + $map[] = $directory.'/'.$file; |
|
20 | 20 | } |
21 | 21 | } |
22 | 22 | |
@@ -56,11 +56,11 @@ discard block |
||
56 | 56 | if ($missing = array_diff($sorted_map, $map)) { |
57 | 57 | throw new \Exception( |
58 | 58 | "Missing file in your classmap. Please add it manually to " |
59 | - . __FILE__ . "\n" |
|
59 | + . __FILE__."\n" |
|
60 | 60 | . var_export($missing, true) |
61 | 61 | ); |
62 | 62 | } |
63 | 63 | |
64 | 64 | foreach ($sorted_map as $filepath) { |
65 | - require_once($root . '/' . $filepath); |
|
65 | + require_once($root.'/'.$filepath); |
|
66 | 66 | } |
@@ -1,7 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | 3 | */ |
4 | -function scandir_r($directory) { |
|
4 | +function scandir_r($directory) |
|
5 | +{ |
|
5 | 6 | // $files = array_slice(scandir($directory, SCANDIR_SORT_NONE), 2); |
6 | 7 | if (! $entries = scandir($directory)) { |
7 | 8 | throw new \InvalidArgumentException("Error during scandir"); |
@@ -57,7 +57,7 @@ |
||
57 | 57 | */ |
58 | 58 | protected function replacePlaceholderWithValue(array $args, $value) |
59 | 59 | { |
60 | - return array_map(function ($arg) use($value) { |
|
60 | + return array_map(function($arg) use($value) { |
|
61 | 61 | return $arg === $this->placeholder ? $value : $arg; |
62 | 62 | }, $args); |
63 | 63 | } |
@@ -23,7 +23,7 @@ |
||
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 | /**/ |
@@ -36,7 +36,7 @@ discard block |
||
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 |
||
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 | } |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | $class = $current_chained_subject; |
159 | 159 | } |
160 | 160 | |
161 | - $callable = $class .'::'. $method_name; |
|
161 | + $callable = $class.'::'.$method_name; |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | $current_chained_subject = call_user_func_array( |
@@ -203,8 +203,8 @@ discard block |
||
203 | 203 | |
204 | 204 | return |
205 | 205 | ($trace[0]['function'] == '__call' || $trace[0]['function'] == '__callStatic') |
206 | - && $trace[0]['class'] == get_class($current_chained_subject) |
|
207 | - && $trace[0]['args'][0] == $method_name |
|
206 | + && $trace[0]['class'] == get_class($current_chained_subject) |
|
207 | + && $trace[0]['args'][0] == $method_name |
|
208 | 208 | && ( |
209 | 209 | $trace[$call_user_func_array_position]['file'] == __FILE__ |
210 | 210 | && $trace[$call_user_func_array_position]['function'] == 'call_user_func_array' |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | * @param mixed $target The target to apply the callchain on |
219 | 219 | * @return mixed The value returned once the call chain is called uppon $target |
220 | 220 | */ |
221 | - public function __invoke($target=null) |
|
221 | + public function __invoke($target = null) |
|
222 | 222 | { |
223 | 223 | $out = $this->checkTarget($target); |
224 | 224 | |
@@ -235,9 +235,9 @@ discard block |
||
235 | 235 | ); |
236 | 236 | } |
237 | 237 | |
238 | - if (! $is_called && ( |
|
239 | - (is_string($out) && is_callable($out .'::'.$call['method'])) |
|
240 | - || (is_object($out) && is_callable(get_class($out) .'::'.$call['method'])) |
|
238 | + if ( ! $is_called && ( |
|
239 | + (is_string($out) && is_callable($out.'::'.$call['method'])) |
|
240 | + || (is_object($out) && is_callable(get_class($out).'::'.$call['method'])) |
|
241 | 241 | ) |
242 | 242 | ) { |
243 | 243 | $is_called = $this->checkMethodIsReallyCallable( |
@@ -248,21 +248,21 @@ discard block |
||
248 | 248 | ); |
249 | 249 | } |
250 | 250 | |
251 | - if (! $is_called && is_callable($call['method'])) { |
|
251 | + if ( ! $is_called && is_callable($call['method'])) { |
|
252 | 252 | $arguments = $this->prepareArgs($call['arguments'], $out); |
253 | 253 | $out = call_user_func_array($call['method'], $arguments); |
254 | 254 | $is_called = true; |
255 | 255 | } |
256 | 256 | |
257 | - if (! $is_called) { |
|
257 | + if ( ! $is_called) { |
|
258 | 258 | throw new \BadMethodCallException( |
259 | - $call['method'] . "() is neither a method of " . get_class($out) |
|
259 | + $call['method']."() is neither a method of ".get_class($out) |
|
260 | 260 | . " nor a function" |
261 | 261 | ); |
262 | 262 | } |
263 | 263 | } |
264 | 264 | else { |
265 | - $out = $out[ $call['entry'] ]; |
|
265 | + $out = $out[$call['entry']]; |
|
266 | 266 | } |
267 | 267 | } |
268 | 268 | catch (\Exception $e) { |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | 'message', |
278 | 278 | $e->getMessage() |
279 | 279 | . "\nWhen applying $callchain_description defined at " |
280 | - . $call['file'] . ':' . $call['line'] |
|
280 | + . $call['file'].':'.$call['line'] |
|
281 | 281 | ); |
282 | 282 | |
283 | 283 | // Throw $e with the good stack (usage exception) |
@@ -41,17 +41,17 @@ discard block |
||
41 | 41 | * @param array $options target: mixed | max_parameter_length: int | short_objects: bool |
42 | 42 | * @return string The PHP code corresponding to this call chain |
43 | 43 | */ |
44 | - public function toString(array $options=[]) |
|
44 | + public function toString(array $options = []) |
|
45 | 45 | { |
46 | 46 | $target = isset($options['target']) ? $options['target'] : $this->expectedTarget; |
47 | 47 | $max_param_length = isset($options['max_parameter_length']) ? $options['max_parameter_length'] : 56; |
48 | 48 | $short_objects = isset($options['short_objects']) ? $options['short_objects'] : true; |
49 | 49 | |
50 | - $string = '(new ' . get_called_class(); |
|
51 | - $target && $string .= '(' . static::varExport($target, [ |
|
50 | + $string = '(new '.get_called_class(); |
|
51 | + $target && $string .= '('.static::varExport($target, [ |
|
52 | 52 | 'short_objects' => $short_objects, |
53 | 53 | 'max_length' => $max_param_length, |
54 | - ]) . ')'; |
|
54 | + ]).')'; |
|
55 | 55 | $string .= ')'; |
56 | 56 | |
57 | 57 | foreach ($this->stack as $i => $call) { |
@@ -67,13 +67,13 @@ discard block |
||
67 | 67 | $string .= ')'; |
68 | 68 | } |
69 | 69 | else { |
70 | - $string .= '[' . static::varExport($call['entry'], [ |
|
70 | + $string .= '['.static::varExport($call['entry'], [ |
|
71 | 71 | 'short_objects' => $short_objects, |
72 | 72 | 'max_length' => $max_param_length, |
73 | - ]) . ']'; |
|
73 | + ]).']'; |
|
74 | 74 | } |
75 | 75 | |
76 | - if (! empty($options['limit']) && $options['limit'] == $i) { |
|
76 | + if ( ! empty($options['limit']) && $options['limit'] == $i) { |
|
77 | 77 | break; |
78 | 78 | } |
79 | 79 | } |
@@ -88,16 +88,16 @@ discard block |
||
88 | 88 | * @param array $options max_length: int | short_objects: bool |
89 | 89 | * @return string The PHP code of the variable |
90 | 90 | */ |
91 | - protected static function varExport($variable, array $options=[]) |
|
91 | + protected static function varExport($variable, array $options = []) |
|
92 | 92 | { |
93 | 93 | $options['max_length'] = isset($options['max_length']) ? $options['max_length'] : 56; |
94 | - $options['short_objects'] = (! empty($options['short_objects'])) || in_array('short_objects', $options); |
|
94 | + $options['short_objects'] = ( ! empty($options['short_objects'])) || in_array('short_objects', $options); |
|
95 | 95 | |
96 | 96 | $export = var_export($variable, true); |
97 | 97 | |
98 | 98 | if ($options['short_objects']) { |
99 | 99 | if (is_object($variable)) { |
100 | - $export = ' ' . get_class($variable) . ' #' . spl_object_id($variable) . ' '; |
|
100 | + $export = ' '.get_class($variable).' #'.spl_object_id($variable).' '; |
|
101 | 101 | } |
102 | 102 | } |
103 | 103 | |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | |
106 | 106 | if (is_object($variable)) { |
107 | 107 | // shortening short objects would only slow the workflow |
108 | - $export = get_class($variable) . ' #' . spl_object_id($variable); |
|
108 | + $export = get_class($variable).' #'.spl_object_id($variable); |
|
109 | 109 | } |
110 | 110 | elseif (is_string($variable)) { |
111 | 111 | $keep_length = floor(($options['max_length'] - 5) / 2); |
@@ -3,7 +3,7 @@ discard block |
||
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 |
||
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 | } |
@@ -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 the target " . spl_object_id($target) . " for the {$callchain} which already has one: " . spl_object_id($expected_target); |
|
28 | + $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); |
|
29 | 29 | } |
30 | 30 | } |
31 | 31 | \ 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 type " . gettype($target) . " for the {$callchain} allowing only: " . $expected_target; |
|
28 | + $this->message = "You are trying to define a target of type ".gettype($target)." for the {$callchain} allowing only: ".$expected_target; |
|
29 | 29 | } |
30 | 30 | } |
31 | 31 | \ No newline at end of file |