1 | <?php |
||
9 | class Application |
||
10 | { |
||
11 | /** |
||
12 | * Container |
||
13 | * |
||
14 | * @var array |
||
15 | */ |
||
16 | private $container = []; |
||
17 | |||
18 | /** |
||
19 | * Set and rename core classes |
||
20 | * |
||
21 | * @var array |
||
22 | */ |
||
23 | private $classes = []; |
||
24 | |||
25 | /** |
||
26 | * Application Object |
||
27 | * |
||
28 | * @var \System\Application |
||
29 | */ |
||
30 | private static $instance; |
||
31 | |||
32 | /** |
||
33 | * Constructor |
||
34 | * |
||
35 | * @property object $file |
||
36 | * @property object $error |
||
37 | * @param \System\File $file |
||
38 | */ |
||
39 | private function __construct(File $file) |
||
53 | |||
54 | /** |
||
55 | * Get Application instance |
||
56 | * |
||
57 | * @param \System\File $file |
||
58 | * @return \System\Application |
||
59 | */ |
||
60 | public static function getInstance(FILE $file) |
||
66 | |||
67 | /** |
||
68 | * Run the Application |
||
69 | * |
||
70 | * @property object $session |
||
71 | * @property object $file |
||
72 | * @property object $route |
||
73 | * @property object $response |
||
74 | * @return void |
||
75 | */ |
||
76 | public function run(): void |
||
91 | |||
92 | /** |
||
93 | * Share the given key|value through Application |
||
94 | * |
||
95 | * @param string $key |
||
96 | * @param mixed $value |
||
97 | * @return void |
||
98 | */ |
||
99 | private function share($key, $value) |
||
106 | |||
107 | /** |
||
108 | * After getting all the folders and sub-folders, it will loop over all of them |
||
109 | * is the class exists: it will process the name and create an object and add it to the $container |
||
110 | * is the class not exists: it will throw an Exception |
||
111 | * |
||
112 | * @property object $file |
||
113 | * @param string $key |
||
114 | * @return void |
||
115 | */ |
||
116 | private function searchForClass($key) |
||
140 | |||
141 | /** |
||
142 | * Get shared value |
||
143 | * When the key exists in the $classes, it will look if it was sharing before |
||
144 | * is not sharing: it will create in an object and add it to the $container |
||
145 | * is sharing: it will grab it direct from the $container |
||
146 | * |
||
147 | * When the key is not exists in the core $classes, the @method searchForClass will be called |
||
148 | * |
||
149 | * @param string $key |
||
150 | * @return object |
||
151 | */ |
||
152 | public function get(string $key) |
||
163 | |||
164 | /** |
||
165 | * Determine if the given key is shared through Application |
||
166 | * |
||
167 | * @param string $key |
||
168 | * @return bool |
||
169 | */ |
||
170 | private function isSharing($key) |
||
174 | |||
175 | /** |
||
176 | * Determine if the given key is an alias to core class |
||
177 | * |
||
178 | * @param string $key |
||
179 | * @return bool |
||
180 | */ |
||
181 | private function isClassAliasIsset($key) |
||
185 | |||
186 | /** |
||
187 | * Create new object for the core class based on the given key |
||
188 | * |
||
189 | * @param string $key |
||
190 | * @return object |
||
191 | */ |
||
192 | private function createObject($key) |
||
198 | |||
199 | /** |
||
200 | * Get shared value dynamically |
||
201 | * |
||
202 | * @param string $key |
||
203 | * @return object |
||
204 | */ |
||
205 | public function __get(string $key) |
||
209 | } |
||
210 |
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.