| 1 | <?php |
||
| 12 | class AllowedHostsMiddleware implements HTTPMiddleware |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * List of allowed hosts |
||
| 16 | * |
||
| 17 | * @var array |
||
| 18 | */ |
||
| 19 | private $allowedHosts = []; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @return array List of allowed Host header values |
||
| 23 | */ |
||
| 24 | public function getAllowedHosts() |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Sets the list of allowed Host header values |
||
| 31 | * Can also specify a comma separated list |
||
| 32 | * |
||
| 33 | * @param array|string $allowedHosts |
||
| 34 | * @return $this |
||
| 35 | */ |
||
| 36 | public function setAllowedHosts($allowedHosts) |
||
| 44 | |||
| 45 | /** |
||
| 46 | * @inheritdoc |
||
| 47 | */ |
||
| 48 | public function process(HTTPRequest $request, callable $delegate) |
||
| 62 | } |
||
| 63 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)or! empty(...)instead.