← All changes
|
vendor/wpfluent/framework/src/WPFluent/Container/BoundMethod.php
+18
-7
1.41
→
2.1.0
View file →
| @@ -22,22 +22,32 @@ | ||
| 22 | 22 | * |
| 23 | 23 | * @throws \ReflectionException |
| 24 | 24 | * @throws \InvalidArgumentException |
| 25 | 25 | */ |
| 26 | - public static function call($container, $callback, array $parameters = [], $defaultMethod = null) | |
| 26 | + public static function call( | |
| 27 | + $container, $callback, array $parameters = [], $defaultMethod = null | |
| 28 | + ) | |
| 27 | 29 | { |
| 28 | - if (is_string($callback) && ! $defaultMethod && method_exists($callback, '__invoke')) { | |
| 30 | + if ( | |
| 31 | + is_string($callback) | |
| 32 | + && ! $defaultMethod | |
| 33 | + && method_exists($callback, '__invoke') | |
| 34 | + ) { | |
| 29 | 35 | $defaultMethod = '__invoke'; |
| 30 | 36 | } |
| 31 | 37 | |
| 32 | 38 | if (static::isCallableWithAtSign($callback) || $defaultMethod) { |
| 33 | - return static::callClass($container, $callback, $parameters, $defaultMethod); | |
| 39 | + return static::callClass( | |
| 40 | + $container, $callback, $parameters, $defaultMethod | |
| 41 | + ); | |
| 34 | 42 | } |
| 35 | 43 | |
| 36 | 44 | return static::callBoundMethod($container, $callback, function () use ($container, $callback, $parameters) { |
| 37 | 45 | return $callback( |
| 38 | 46 | ...array_values( |
| 39 | - static::getMethodDependencies($container, $callback, $parameters) | |
| 47 | + static::getMethodDependencies( | |
| 48 | + $container, $callback, $parameters | |
| 49 | + ) | |
| 40 | 50 | ) |
| 41 | 51 | ); |
| 42 | 52 | }); |
| 43 | 53 | } |
| @@ -52,9 +62,11 @@ | ||
| 52 | 62 | * @return mixed |
| 53 | 63 | * |
| 54 | 64 | * @throws \InvalidArgumentException |
| 55 | 65 | */ |
| 56 | - protected static function callClass($container, $target, array $parameters = [], $defaultMethod = null) | |
| 66 | + protected static function callClass( | |
| 67 | + $container, $target, array $parameters = [], $defaultMethod = null | |
| 68 | + ) | |
| 57 | 69 | { |
| 58 | 70 | $segments = explode('@', $target); |
| 59 | 71 | |
| 60 | 72 | // We will assume an @ sign is used to delimit the class name from the method |
| @@ -59,10 +71,9 @@ | ||
| 59 | 71 | |
| 60 | 72 | // We will assume an @ sign is used to delimit the class name from the method |
| 61 | 73 | // name. We will split on this @ sign and then build a callable array that |
| 62 | 74 | // we can pass right back into the "call" method for dependency binding. |
| 63 | - $method = count($segments) === 2 | |
| 64 | - ? $segments[1] : $defaultMethod; | |
| 75 | + $method = count($segments) === 2 ? $segments[1] : $defaultMethod; | |
| 65 | 76 | |
| 66 | 77 | if (is_null($method)) { |
| 67 | 78 | throw new InvalidArgumentException('Method not provided.'); |
| 68 | 79 | } |