1 | <?php |
||
16 | class Janitor |
||
17 | { |
||
18 | /** |
||
19 | * List of watchers. |
||
20 | * |
||
21 | * @var array |
||
22 | */ |
||
23 | protected $watchers = []; |
||
24 | |||
25 | /** |
||
26 | * List of excluders. |
||
27 | * |
||
28 | * @var array |
||
29 | */ |
||
30 | protected $excluders = []; |
||
31 | |||
32 | /** |
||
33 | * Resolve handler. |
||
34 | * |
||
35 | * @var callable |
||
36 | */ |
||
37 | protected $handler; |
||
38 | |||
39 | /** |
||
40 | * Request attribute name to store currently active watcher. |
||
41 | * |
||
42 | * @var \Janitor\Watcher |
||
43 | */ |
||
44 | protected $attributeName; |
||
45 | |||
46 | /** |
||
47 | * @param array $watchers |
||
48 | * @param array $excluders |
||
49 | * @param \Janitor\Handler|null $handler |
||
|
|||
50 | * @param string $requestAttribute |
||
51 | */ |
||
52 | public function __construct( |
||
69 | |||
70 | /** |
||
71 | * Add maintenance watcher. |
||
72 | * |
||
73 | * @param \Janitor\Watcher $watcher |
||
74 | */ |
||
75 | public function addWatcher(Watcher $watcher) |
||
81 | |||
82 | /** |
||
83 | * Add excluder condition. |
||
84 | * |
||
85 | * @param \Janitor\Excluder $excluder |
||
86 | */ |
||
87 | public function addExcluder(Excluder $excluder) |
||
93 | |||
94 | /** |
||
95 | * Set handler. |
||
96 | * |
||
97 | * @param callable $handler |
||
98 | */ |
||
99 | public function setHandler(callable $handler) |
||
105 | |||
106 | /** |
||
107 | * Set request attribute name to store active watcher. |
||
108 | * |
||
109 | * @param string $attributeName |
||
110 | */ |
||
111 | public function setAttributeName($attributeName) |
||
117 | |||
118 | /** |
||
119 | * Get next scheduled time spans. |
||
120 | * |
||
121 | * Returns an array of ['start' => \DateTime, 'end' => \DateTime] |
||
122 | * |
||
123 | * @param int $count |
||
124 | * |
||
125 | * @return array |
||
126 | */ |
||
127 | public function getScheduledTimes($count = 5) |
||
150 | |||
151 | /** |
||
152 | * Run middleware. |
||
153 | * |
||
154 | * @param \Psr\Http\Message\ServerRequestInterface $request |
||
155 | * @param \Psr\Http\Message\ResponseInterface $response |
||
156 | * @param \Janitor\Watcher $watcher |
||
157 | * |
||
158 | * @return \Psr\Http\Message\ResponseInterface |
||
159 | */ |
||
160 | public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next) |
||
174 | |||
175 | /** |
||
176 | * Get currenlty active watcher. |
||
177 | * |
||
178 | * @return \Janitor\Watcher|null |
||
179 | */ |
||
180 | protected function getActiveWatcher() |
||
190 | |||
191 | /** |
||
192 | * Whether excluding conditions are met. |
||
193 | * |
||
194 | * @param \Psr\Http\Message\ServerRequestInterface $request |
||
195 | * |
||
196 | * @return bool |
||
197 | */ |
||
198 | protected function isExcluded(ServerRequestInterface $request) |
||
208 | |||
209 | /** |
||
210 | * Retrieve handler. |
||
211 | * |
||
212 | * @return callable |
||
213 | */ |
||
214 | protected function getHandler() |
||
222 | } |
||
223 |
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. In addition it looks for parameters that have the generic type
array
and suggests a stricter type likearray<String>
.Most often this is a case of a parameter that can be null in addition to its declared types.