1 | <?php |
||
11 | trait RouteReflection |
||
12 | { |
||
13 | /** @var array */ |
||
14 | protected static $numberOfParameters = []; |
||
15 | |||
16 | /** @var */ |
||
17 | protected static $reflectionObject; |
||
18 | |||
19 | /** @var null */ |
||
20 | protected static $resolveMethodName = null; |
||
21 | |||
22 | /** |
||
23 | * ... |
||
24 | * |
||
25 | * @return mixed |
||
26 | */ |
||
27 | protected function handleRequestCallable() |
||
33 | |||
34 | /** |
||
35 | * ... |
||
36 | * |
||
37 | * @return mixed |
||
38 | */ |
||
39 | protected function handleRequestController() |
||
46 | |||
47 | /** |
||
48 | * @param object $object |
||
49 | * @param string|null $method |
||
50 | */ |
||
51 | protected static function createReflection($object, string $method = null) |
||
56 | |||
57 | /** |
||
58 | * @param int $position |
||
59 | * @return mixed |
||
60 | */ |
||
61 | protected static function getPointersAndReturnRequired(int $position) |
||
65 | |||
66 | /** |
||
67 | * ... |
||
68 | * @return array |
||
69 | */ |
||
70 | protected static function resolveParameters() |
||
90 | |||
91 | /** |
||
92 | * Check whether injected class is registered in container. |
||
93 | * |
||
94 | * @param string $className |
||
95 | * @return bool |
||
96 | */ |
||
97 | protected static function checkClassRegisterContainer(string $className) |
||
104 | |||
105 | /** |
||
106 | * Get all parameters to object |
||
107 | * |
||
108 | * @return mixed |
||
109 | */ |
||
110 | protected static function getParametersObject() |
||
120 | } |
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idable
provides a methodequalsId
that in turn relies on the methodgetId()
. If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()
as an abstract method to the trait will make sure it is available.