1 | <?php |
||
12 | class Facade extends LaravelFacade |
||
13 | { |
||
14 | protected static $tmpDriver = null; |
||
15 | |||
16 | /** |
||
17 | * Get the registered name of the component. |
||
18 | * |
||
19 | * @return string |
||
20 | */ |
||
21 | 9 | protected static function getFacadeAccessor() |
|
22 | { |
||
23 | 9 | if ($tmp = static::$tmpDriver) { |
|
24 | 2 | static::$tmpDriver = null; |
|
25 | |||
26 | 2 | return $tmp; |
|
27 | } |
||
28 | |||
29 | 9 | return static::class; |
|
30 | } |
||
31 | |||
32 | /** |
||
33 | * Temporarily changes the driver, only for the next call. |
||
34 | * |
||
35 | * @param \Closure|string $name |
||
36 | * |
||
37 | * @return string |
||
38 | */ |
||
39 | 2 | public static function changeProxyTo($name) |
|
40 | { |
||
41 | 2 | static::$tmpDriver = $name; |
|
42 | |||
43 | 2 | return static::class; |
|
44 | } |
||
45 | |||
46 | /** |
||
47 | * Temporarily changes the driver, only for the next call. |
||
48 | * |
||
49 | * @param \Closure|string $name |
||
50 | * |
||
51 | * @return string |
||
52 | */ |
||
53 | 1 | public static function withDriver($name) |
|
54 | { |
||
55 | 1 | return static::changeProxyTo($name); |
|
56 | } |
||
57 | |||
58 | /** |
||
59 | * Changes the default driver of the facade. |
||
60 | * |
||
61 | * @param \Closure|string $name |
||
|
|||
62 | * |
||
63 | * @return string |
||
64 | */ |
||
65 | 9 | public static function shouldProxyTo($class) |
|
66 | { |
||
67 | 9 | static::$app->singleton(self::getFacadeAccessor(), $class); |
|
68 | |||
69 | 9 | return static::class; |
|
70 | } |
||
71 | |||
72 | /** |
||
73 | * Sets up a listener to be invoked before the actual method call. |
||
74 | * |
||
75 | * @param string $methodName |
||
76 | * @param \Closure|string $listener |
||
77 | */ |
||
78 | 3 | public static function preCall($methodName, $listener) |
|
79 | { |
||
80 | 3 | $listener = self::makeListener($methodName, $listener); |
|
81 | |||
82 | 3 | Event::listen('calling: '.static::class.'@'.$methodName, $listener); |
|
83 | 3 | } |
|
84 | |||
85 | /** |
||
86 | * Sets up a listener to be invoked after the actual method. |
||
87 | * |
||
88 | * @param string $methodName |
||
89 | * @param \Closure|string $listener |
||
90 | */ |
||
91 | 3 | public static function postCall($methodName, $listener) |
|
92 | { |
||
93 | 3 | $listener = self::makeListener($methodName, $listener); |
|
94 | |||
95 | 3 | Event::listen('called: '.static::class.'@'.$methodName, $listener); |
|
96 | 3 | } |
|
97 | |||
98 | /** |
||
99 | * Handle dynamic, static calls to the object. |
||
100 | * |
||
101 | * @param string $method |
||
102 | * @param array $args |
||
103 | * @return mixed |
||
104 | * |
||
105 | * @throws \RuntimeException |
||
106 | * @throws \ReflectionException |
||
107 | */ |
||
108 | 8 | public static function __callStatic($method, $args) |
|
131 | |||
132 | /** |
||
133 | * Adds missing dependencies to the user-provided input. |
||
134 | * |
||
135 | * @param ReflectionParameter[] $parameters |
||
136 | * @param array $inputData |
||
137 | */ |
||
138 | 4 | private static function addMissingDependencies($parameters, array &$inputData) |
|
150 | |||
151 | 3 | private static function makeListener(string $method, $listener) |
|
169 | } |
||
170 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.