| 1 | <?php |
||
| 8 | class Config |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * The \Noodlehaus\Config object. |
||
| 12 | * |
||
| 13 | * @var \Noodlehaus\Config |
||
| 14 | */ |
||
| 15 | protected $config; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * The input for the config object. |
||
| 19 | * |
||
| 20 | * @var string|array |
||
| 21 | */ |
||
| 22 | protected $configInput; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Create new Config service provider. |
||
| 26 | * |
||
| 27 | * @param string|array|ArrayAccess $configInput |
||
| 28 | */ |
||
| 29 | public function __construct($configInput) |
||
| 33 | |||
| 34 | /** |
||
| 35 | * Config middleware invokable class. |
||
| 36 | * |
||
| 37 | * @param \Psr\Http\Message\ServerRequestInterface $request PSR7 request |
||
| 38 | * @param \Psr\Http\Message\ResponseInterface $response PSR7 response |
||
| 39 | * @param callable $next Next middleware |
||
| 40 | * |
||
| 41 | * @return \Psr\Http\Message\ResponseInterface |
||
| 42 | */ |
||
| 43 | public function __invoke($request, $response, $next) |
||
| 49 | |||
| 50 | /** |
||
| 51 | * Get the config object. |
||
| 52 | * |
||
| 53 | * @return \Noodlehaus\Config |
||
| 54 | */ |
||
| 55 | public function getConfig() |
||
| 59 | |||
| 60 | /** |
||
| 61 | * Set config. |
||
| 62 | * |
||
| 63 | * @param \Noodlehaus\Config $config The validators array. |
||
| 64 | */ |
||
| 65 | public function setConfig($config) |
||
| 69 | |||
| 70 | /** |
||
| 71 | * Get config input. |
||
| 72 | * |
||
| 73 | * @return string|array|ArrayAccess The config input. |
||
| 74 | */ |
||
| 75 | public function getConfigInput() |
||
| 79 | } |
||
| 80 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountIdthat can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theidproperty of an instance of theAccountclass. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.