1 | <?php |
||
17 | class Application extends Dispatcher implements \ArrayAccess |
||
18 | { |
||
19 | /** |
||
20 | * Application name |
||
21 | * @var string |
||
22 | */ |
||
23 | protected $name; |
||
24 | |||
25 | /** |
||
26 | * List of registered actions |
||
27 | * @var array |
||
28 | */ |
||
29 | protected $actions = array(); |
||
30 | |||
31 | /** |
||
32 | * Services container (Di) |
||
33 | * @var Container |
||
34 | */ |
||
35 | protected $services; |
||
36 | |||
37 | /** |
||
38 | * The default action (i.e the "homepage") |
||
39 | * @var string |
||
40 | */ |
||
41 | protected $defaultAction; |
||
42 | |||
43 | /** |
||
44 | * Constructor |
||
45 | * |
||
46 | * @param string $name Application name |
||
47 | * @param Container $services Services Container (di) |
||
|
|||
48 | * |
||
49 | * @return void |
||
50 | */ |
||
51 | 44 | public function __construct($name, Container $services = null) |
|
61 | |||
62 | /** |
||
63 | * Registers an action |
||
64 | * |
||
65 | * @param string $actionName Name of the action |
||
66 | * @param ActionProxy $proxy Proxy instance to the action |
||
67 | * |
||
68 | * @return Application |
||
69 | */ |
||
70 | 33 | public function register($actionName, ActionProxy $proxy) |
|
76 | |||
77 | /** |
||
78 | * Unregisters an action |
||
79 | * |
||
80 | * @param string $actionName Name of the action |
||
81 | * |
||
82 | * @return Application |
||
83 | * @throws Exception if action is not registered |
||
84 | */ |
||
85 | 2 | public function unregister($actionName) |
|
95 | |||
96 | /** |
||
97 | * Returns the ActionProxy of a registered action |
||
98 | * |
||
99 | * @param string $actionName name of the action |
||
100 | * |
||
101 | * @return ActionProxy the proxy instance to the action |
||
102 | * @throws Exception if action is not registered |
||
103 | */ |
||
104 | 25 | public function get($actionName) |
|
112 | |||
113 | /** |
||
114 | * Tells if an action is registered |
||
115 | * |
||
116 | * @param string $actionName Name of the action |
||
117 | * |
||
118 | * @return boolean |
||
119 | */ |
||
120 | 28 | public function exists($actionName) |
|
124 | |||
125 | /** |
||
126 | * Returns the list (array) of all registered actions (keys) and their |
||
127 | * according ActionProxy (values) |
||
128 | * |
||
129 | * @return array |
||
130 | */ |
||
131 | 1 | public function getActions() |
|
135 | |||
136 | /** |
||
137 | * Instanciates a new Application |
||
138 | * (useful for chaining) |
||
139 | * |
||
140 | * @param string $name Application name |
||
141 | * @param Container $services Services Container |
||
142 | * |
||
143 | * @return Application App instance |
||
144 | */ |
||
145 | 38 | public static function factory($name, Container $services = null) |
|
149 | |||
150 | /** |
||
151 | * Returns the Application name |
||
152 | * |
||
153 | * @return string |
||
154 | */ |
||
155 | 1 | public function getName() |
|
159 | |||
160 | /** |
||
161 | * Returns the Services Container |
||
162 | * |
||
163 | * @return Container |
||
164 | */ |
||
165 | 35 | public function getServices() |
|
169 | |||
170 | /** |
||
171 | * Defines a Services Container |
||
172 | * |
||
173 | * @param Container $services Services Container (Di) |
||
174 | * |
||
175 | * @return Application |
||
176 | */ |
||
177 | public function setServices(Container $services) |
||
183 | |||
184 | /** |
||
185 | * Runs the Application for a defined (or new) HTTP request |
||
186 | * |
||
187 | * @param Request $request The HTTP request (optional) |
||
188 | * |
||
189 | * @return mixed |
||
190 | */ |
||
191 | 27 | public function run(Request $request = null) |
|
257 | |||
258 | /** |
||
259 | * |
||
260 | * @param Context $context |
||
261 | * |
||
262 | * @return mixed |
||
263 | */ |
||
264 | 24 | public function runAction(Context $context) |
|
285 | |||
286 | /** |
||
287 | * Returns the default action name (if any) |
||
288 | * |
||
289 | * @return string |
||
290 | */ |
||
291 | 2 | public function getDefaultAction() |
|
295 | |||
296 | /** |
||
297 | * Defines a default action. Basically the one which answers on / |
||
298 | * |
||
299 | * @param string $defaultAction Default action name |
||
300 | * |
||
301 | * @return Application |
||
302 | */ |
||
303 | 2 | public function setDefaultAction($defaultAction) |
|
309 | |||
310 | 2 | public function offsetExists($actionName) |
|
314 | |||
315 | 1 | public function offsetGet($actionName) |
|
319 | |||
320 | 12 | public function offsetSet($actionName, $proxy) |
|
328 | |||
329 | 1 | public function offsetUnset($actionName) |
|
333 | |||
334 | /** |
||
335 | * Adds a Plugin to the Application. |
||
336 | * |
||
337 | * @param Plugin $plugin The plugin to be loaded |
||
338 | * |
||
339 | * @return Application |
||
340 | */ |
||
341 | 1 | public function plugin(Plugin $plugin) |
|
353 | } |
This check looks for
@param
annotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.