1 | <?php |
||
12 | Trait HasModule |
||
13 | { |
||
14 | /** |
||
15 | * Sub-modules of this plugin |
||
16 | * |
||
17 | * @since 1.0.0 |
||
18 | * @var array |
||
19 | */ |
||
20 | protected $modules; |
||
21 | |||
22 | /** |
||
23 | * Load neccessary sub-modules for the this class. |
||
24 | * |
||
25 | * @since 1.0.0 |
||
26 | * @return \WPDFI\Traits\HasModule |
||
|
|||
27 | */ |
||
28 | abstract public function loadModules(); |
||
29 | |||
30 | /** |
||
31 | * Magic method to get properties |
||
32 | * |
||
33 | * @since 1.0.0 |
||
34 | * |
||
35 | * @param string $name |
||
36 | * @return mixed |
||
37 | */ |
||
38 | public function __get($name) |
||
50 | |||
51 | /** |
||
52 | * Trigger hook actions of all sub-modules |
||
53 | * |
||
54 | * @since 1.0.0 |
||
55 | * @return void |
||
56 | */ |
||
57 | public function moduleHooks() { |
||
64 | |||
65 | /** |
||
66 | * Load a sub-module or add a new sub-module to the vatweets(). |
||
67 | * |
||
68 | * @param string $name |
||
69 | * @param mixed $handle |
||
70 | * @since 1.0.0 |
||
71 | * @return mixed $handle |
||
72 | */ |
||
73 | public function module($name, $handle = null) { |
||
78 | } |
In PHP traits cannot be used for type-hinting as they do not define a well-defined structure. This is because any class that uses a trait can rename that trait’s methods.
If you would like to return an object that has a guaranteed set of methods, you could create a companion interface that lists these methods explicitly.