1 | <?php |
||
24 | class Runner |
||
25 | { |
||
26 | /** |
||
27 | * List of watchers. |
||
28 | * |
||
29 | * @var array |
||
30 | */ |
||
31 | protected $watchers = []; |
||
32 | |||
33 | /** |
||
34 | * List of excluders. |
||
35 | * |
||
36 | * @var array |
||
37 | */ |
||
38 | protected $excluders = []; |
||
39 | |||
40 | /** |
||
41 | * Resolve handler. |
||
42 | * |
||
43 | * @var callable |
||
44 | */ |
||
45 | protected $handler; |
||
46 | |||
47 | /** |
||
48 | * Request attribute name to store currently active watcher. |
||
49 | * |
||
50 | * @var string |
||
51 | */ |
||
52 | protected $attributeName; |
||
53 | |||
54 | /** |
||
55 | * Runner constructor. |
||
56 | * |
||
57 | * @param array $watchers |
||
58 | * @param array $excluders |
||
59 | * @param callable $handler |
||
|
|||
60 | * @param string $attributeName |
||
61 | */ |
||
62 | public function __construct( |
||
79 | |||
80 | /** |
||
81 | * Add maintenance watcher. |
||
82 | * |
||
83 | * @param WatcherInterface $watcher |
||
84 | * |
||
85 | * @return $this |
||
86 | */ |
||
87 | public function addWatcher(WatcherInterface $watcher) |
||
93 | |||
94 | /** |
||
95 | * Add excluder condition. |
||
96 | * |
||
97 | * @param ExcluderInterface $excluder |
||
98 | * |
||
99 | * @return $this |
||
100 | */ |
||
101 | public function addExcluder(ExcluderInterface $excluder) |
||
107 | |||
108 | /** |
||
109 | * Set handler. |
||
110 | * |
||
111 | * @param callable $handler |
||
112 | * |
||
113 | * @return $this |
||
114 | */ |
||
115 | public function setHandler(callable $handler) |
||
121 | |||
122 | /** |
||
123 | * Set request attribute name to store active watcher. |
||
124 | * |
||
125 | * @param string $attributeName |
||
126 | * |
||
127 | * @return $this |
||
128 | */ |
||
129 | public function setAttributeName($attributeName) |
||
135 | |||
136 | /** |
||
137 | * Retrieve request attribute name storing active watcher. |
||
138 | * |
||
139 | * @return string |
||
140 | */ |
||
141 | public function getAttributeName() |
||
145 | |||
146 | /** |
||
147 | * Get next scheduled time spans. |
||
148 | * |
||
149 | * Returns an array of ['start' => \DateTime, 'end' => \DateTime] |
||
150 | * |
||
151 | * @param int $count |
||
152 | * |
||
153 | * @return array |
||
154 | */ |
||
155 | public function getScheduledTimes($count = 5) |
||
178 | |||
179 | /** |
||
180 | * Run middleware. |
||
181 | * |
||
182 | * @param ServerRequestInterface $request |
||
183 | * @param ResponseInterface $response |
||
184 | * @param callable $next |
||
185 | * |
||
186 | * @return ResponseInterface |
||
187 | */ |
||
188 | public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next) |
||
202 | |||
203 | /** |
||
204 | * Get currently active watcher. |
||
205 | * |
||
206 | * @return WatcherInterface |
||
207 | */ |
||
208 | protected function getActiveWatcher() |
||
216 | |||
217 | /** |
||
218 | * Whether excluding conditions are met. |
||
219 | * |
||
220 | * @param ServerRequestInterface $request |
||
221 | * |
||
222 | * @return bool |
||
223 | */ |
||
224 | protected function isExcluded(ServerRequestInterface $request) |
||
234 | |||
235 | /** |
||
236 | * Retrieve handler. |
||
237 | * |
||
238 | * @return callable |
||
239 | */ |
||
240 | protected function getHandler() |
||
248 | } |
||
249 |
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.