1 | <?php |
||
12 | trait BootstrapAwareTrait |
||
13 | { |
||
14 | |||
15 | /** |
||
16 | * Indicates if the application has been bootstrapped before. |
||
17 | * |
||
18 | * @var bool |
||
19 | */ |
||
20 | protected $hasBeenBootstrapped = false; |
||
21 | |||
22 | /** |
||
23 | * The bootstrap classes for the application. |
||
24 | * |
||
25 | * @var null|AbstractBootstraper[] |
||
26 | */ |
||
27 | protected $bootstrappers = null; |
||
28 | |||
29 | /** |
||
30 | * Bootstrap the application for HTTP requests. |
||
31 | * |
||
32 | * @return void |
||
33 | */ |
||
34 | public function bootstrap() |
||
40 | |||
41 | /** |
||
42 | * Determine if the application has been bootstrapped before. |
||
43 | * |
||
44 | * @return bool |
||
45 | */ |
||
46 | public function hasBeenBootstrapped() |
||
50 | |||
51 | /** |
||
52 | * Run the given array of bootstrap classes. |
||
53 | * |
||
54 | * @param array $bootstrappers |
||
55 | * @return void |
||
56 | */ |
||
57 | public function bootstrapWith(array $bootstrappers) |
||
64 | |||
65 | /** |
||
66 | * @param $bootstrapper |
||
67 | * @return AbstractBootstraper |
||
68 | */ |
||
69 | public function getBootstrap($bootstrapper) |
||
76 | |||
77 | /** |
||
78 | * Get the bootstrap classes for the application. |
||
79 | * |
||
80 | * @return array |
||
81 | */ |
||
82 | protected function bootstrappers() |
||
89 | |||
90 | /** |
||
91 | * @param AbstractBootstraper $bootstrapper |
||
92 | */ |
||
93 | protected function addBootstrapper($bootstrapper) |
||
97 | |||
98 | protected function initBootstrappers() |
||
102 | |||
103 | /** |
||
104 | * @return AbstractBootstraper[] |
||
105 | */ |
||
106 | protected function getDefaultBootstrappers() |
||
110 | } |
||
111 |
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.