These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * @author jan huang <[email protected]> |
||
4 | * @copyright 2016 |
||
5 | * |
||
6 | * @see https://www.github.com/janhuang |
||
7 | * @see https://fastdlabs.com |
||
8 | */ |
||
9 | use FastD\Application; |
||
10 | use FastD\Config\Config; |
||
11 | use FastD\Http\JsonResponse; |
||
12 | use FastD\Http\Response; |
||
13 | use FastD\Model\Database; |
||
14 | use FastD\Model\Model; |
||
15 | use FastD\Model\ModelFactory; |
||
16 | use FastD\Packet\Swoole; |
||
17 | use FastD\Routing\RouteCollection; |
||
18 | use Monolog\Logger; |
||
19 | use Psr\Http\Message\ServerRequestInterface; |
||
20 | use Symfony\Component\Cache\Adapter\AbstractAdapter; |
||
21 | |||
22 | /** |
||
23 | * @return Application |
||
24 | */ |
||
25 | function app() |
||
26 | { |
||
27 | return Application::$app; |
||
28 | } |
||
29 | |||
30 | /** |
||
31 | * @return string |
||
32 | */ |
||
33 | function version() |
||
34 | { |
||
35 | return Application::VERSION; |
||
36 | } |
||
37 | |||
38 | /** |
||
39 | * @return RouteCollection |
||
40 | */ |
||
41 | function route() |
||
42 | { |
||
43 | return app()->get('router'); |
||
44 | } |
||
45 | |||
46 | /** |
||
47 | * @return Config |
||
48 | */ |
||
49 | function config() |
||
50 | { |
||
51 | return app()->get('config'); |
||
52 | } |
||
53 | |||
54 | /** |
||
55 | * @return ServerRequestInterface |
||
56 | */ |
||
57 | function request() |
||
58 | { |
||
59 | return app()->get('request'); |
||
60 | } |
||
61 | |||
62 | /** |
||
63 | * @return Response |
||
64 | */ |
||
65 | function response() |
||
66 | { |
||
67 | return app()->get('response'); |
||
68 | } |
||
69 | |||
70 | /** |
||
71 | * @param array $content |
||
72 | * @param int $statusCode |
||
73 | * |
||
74 | * @return Response |
||
75 | */ |
||
76 | function binary(array $content, $statusCode = Response::HTTP_OK) |
||
77 | { |
||
78 | return new Response(Swoole::encode($content), $statusCode); |
||
79 | } |
||
80 | |||
81 | /** |
||
82 | * @param array $content |
||
83 | * @param int $statusCode |
||
84 | * |
||
85 | * @return Response |
||
86 | */ |
||
87 | function json(array $content = [], $statusCode = Response::HTTP_OK) |
||
88 | { |
||
89 | return new JsonResponse($content, $statusCode); |
||
90 | } |
||
91 | |||
92 | /** |
||
93 | * @param $statusCode |
||
94 | * @param $message |
||
95 | * |
||
96 | * @throws Exception |
||
97 | */ |
||
98 | function abort($statusCode, $message = null) |
||
99 | { |
||
100 | throw new Exception((is_null($message) ? Response::$statusTexts[$statusCode] : $message), $statusCode); |
||
101 | } |
||
102 | |||
103 | /** |
||
104 | * @return Logger |
||
105 | */ |
||
106 | function logger() |
||
107 | { |
||
108 | return app()->get('logger'); |
||
109 | } |
||
110 | |||
111 | /** |
||
112 | * @param $key |
||
113 | * |
||
114 | * @return AbstractAdapter |
||
115 | */ |
||
116 | function cache($key = 'default') |
||
117 | { |
||
118 | return app()->get('cache')->getCache($key); |
||
119 | } |
||
120 | |||
121 | /** |
||
122 | * @param $key |
||
123 | * |
||
124 | * @return Database |
||
125 | */ |
||
126 | function database($key = 'default') |
||
127 | { |
||
128 | return app()->get('database')->getConnection($key); |
||
129 | } |
||
130 | |||
131 | /** |
||
132 | * @param $name |
||
133 | * @param $key |
||
134 | * |
||
135 | * @return Model |
||
136 | */ |
||
137 | function model($name, $key = 'default') |
||
138 | { |
||
139 | return ModelFactory::createModel($name, $key); |
||
140 | } |
||
141 | |||
142 | function client() |
||
143 | { |
||
144 | } |
||
145 | |||
146 | /** |
||
147 | * @return \swoole_server |
||
148 | */ |
||
149 | function server() |
||
150 | { |
||
151 | return app()->get('server'); |
||
152 | } |
||
153 | |||
154 | /** |
||
155 | * @param $fd |
||
156 | * |
||
157 | * @return Response |
||
158 | */ |
||
159 | function message($fd) |
||
0 ignored issues
–
show
|
|||
160 | { |
||
161 | } |
||
162 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.