@@ -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; |
@@ -24,7 +24,7 @@ |
||
| 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 | /**/ |
@@ -24,7 +24,7 @@ |
||
| 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 | /**/ |
@@ -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 | /**/ |
@@ -24,7 +24,7 @@ |
||
| 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 | /**/ |
@@ -24,7 +24,7 @@ |
||
| 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 | /**/ |
@@ -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 | } |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | * |
| 35 | 35 | * @param string $class_type_interface_or_instance The expected target class/type/interface/instance |
| 36 | 36 | */ |
| 37 | - public function __construct($class_type_interface_or_instance=null) |
|
| 37 | + public function __construct($class_type_interface_or_instance = null) |
|
| 38 | 38 | { |
| 39 | 39 | if ($class_type_interface_or_instance) { |
| 40 | 40 | $this->expectedTarget = $class_type_interface_or_instance; |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | * |
| 109 | 109 | * @return string The PHP code corresponding to this call chain |
| 110 | 110 | */ |
| 111 | - protected function toString(array $options=[]) |
|
| 111 | + protected function toString(array $options = []) |
|
| 112 | 112 | { |
| 113 | 113 | $target = isset($options['target']) ? $options['target'] : $this->expectedTarget; |
| 114 | 114 | |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | foreach ($this->stack as $i => $call) { |
| 120 | 120 | if (isset($call['method'])) { |
| 121 | 121 | $string .= '->'; |
| 122 | - $string .= $call['method'].'('; |
|
| 122 | + $string .= $call['method'] . '('; |
|
| 123 | 123 | $string .= implode(', ', array_map(function($argument) { |
| 124 | 124 | return static::varExport($argument, ['short_objects']); |
| 125 | 125 | }, $call['arguments'])); |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | $string .= '[' . static::varExport($call['entry'], ['short_objects']) . ']'; |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | - if (! empty($options['limit']) && $options['limit'] == $i) { |
|
| 132 | + if (!empty($options['limit']) && $options['limit'] == $i) { |
|
| 133 | 133 | break; |
| 134 | 134 | } |
| 135 | 135 | } |
@@ -144,10 +144,10 @@ discard block |
||
| 144 | 144 | * @param array $options max_length | alias_instances |
| 145 | 145 | * @return string The PHP code of the variable |
| 146 | 146 | */ |
| 147 | - protected static function varExport($variable, array $options=[]) |
|
| 147 | + protected static function varExport($variable, array $options = []) |
|
| 148 | 148 | { |
| 149 | 149 | $options['max_length'] = isset($options['max_length']) ? $options['max_length'] : 512; |
| 150 | - $options['short_objects'] = ! empty($options['short_objects']) || in_array('short_objects', $options); |
|
| 150 | + $options['short_objects'] = !empty($options['short_objects']) || in_array('short_objects', $options); |
|
| 151 | 151 | |
| 152 | 152 | $export = var_export($variable, true); |
| 153 | 153 | |
@@ -193,12 +193,12 @@ discard block |
||
| 193 | 193 | } |
| 194 | 194 | elseif (is_string($this->expectedTarget)) { |
| 195 | 195 | if (class_exists($this->expectedTarget)) { |
| 196 | - if (! $target instanceof $this->expectedTarget) { |
|
| 196 | + if (!$target instanceof $this->expectedTarget) { |
|
| 197 | 197 | throw new BadTargetClassException($this, $this->expectedTarget, $target); |
| 198 | 198 | } |
| 199 | 199 | } |
| 200 | 200 | elseif (interface_exists($this->expectedTarget)) { |
| 201 | - if (! $target instanceof $this->expectedTarget) { |
|
| 201 | + if (!$target instanceof $this->expectedTarget) { |
|
| 202 | 202 | throw new BadTargetInterfaceException($this, $this->expectedTarget, $target); |
| 203 | 203 | } |
| 204 | 204 | } |
@@ -279,8 +279,8 @@ discard block |
||
| 279 | 279 | |
| 280 | 280 | return |
| 281 | 281 | $trace[0]['function'] == '__call' |
| 282 | - && $trace[0]['class'] == get_class($current_chained_subject) |
|
| 283 | - && $trace[0]['args'][0] == $method_name |
|
| 282 | + && $trace[0]['class'] == get_class($current_chained_subject) |
|
| 283 | + && $trace[0]['args'][0] == $method_name |
|
| 284 | 284 | && ( |
| 285 | 285 | $trace[$call_user_func_array_position]['file'] == __FILE__ |
| 286 | 286 | && $trace[$call_user_func_array_position]['function'] == 'call_user_func_array' |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | * @param mixed $target The target to apply the callchain on |
| 295 | 295 | * @return mixed The value returned once the call chain is called uppon $target |
| 296 | 296 | */ |
| 297 | - public function __invoke($target=null) |
|
| 297 | + public function __invoke($target = null) |
|
| 298 | 298 | { |
| 299 | 299 | $out = $this->checkTarget($target); |
| 300 | 300 | |
@@ -310,13 +310,13 @@ discard block |
||
| 310 | 310 | ); |
| 311 | 311 | } |
| 312 | 312 | |
| 313 | - if (! $is_called && is_callable($call['method'])) { |
|
| 313 | + if (!$is_called && is_callable($call['method'])) { |
|
| 314 | 314 | $arguments = $this->prepareArgs($call['arguments'], $out); |
| 315 | 315 | $out = call_user_func_array($call['method'], $arguments); |
| 316 | 316 | $is_called = true; |
| 317 | 317 | } |
| 318 | 318 | |
| 319 | - if (! $is_called) { |
|
| 319 | + if (!$is_called) { |
|
| 320 | 320 | throw new \BadMethodCallException( |
| 321 | 321 | $call['method'] . "() is neither a method of " . get_class($out) |
| 322 | 322 | . " nor a function" |
@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | } |
| 325 | 325 | } |
| 326 | 326 | else { |
| 327 | - $out = $out[ $call['entry'] ]; |
|
| 327 | + $out = $out[$call['entry']]; |
|
| 328 | 328 | } |
| 329 | 329 | } |
| 330 | 330 | catch (\Exception $e) { |