Checks if the types of returned expressions are compatible with the hinted types.
1 | <?php |
||
2 | /** |
||
3 | * This file is part of the Divergence package. |
||
4 | * |
||
5 | * (c) Henry Paradiz <[email protected]> |
||
6 | * |
||
7 | * For the full copyright and license information, please view the LICENSE |
||
8 | * file that was distributed with this source code. |
||
9 | */ |
||
10 | |||
11 | namespace Divergence\Controllers; |
||
12 | |||
13 | use Psr\Http\Message\ResponseInterface; |
||
14 | use Psr\Http\Message\ServerRequestInterface; |
||
15 | |||
16 | class SiteRequestHandler extends RequestHandler |
||
17 | { |
||
18 | public function handle(ServerRequestInterface $request): ResponseInterface |
||
19 | { |
||
20 | // @codeCoverageIgnoreStart |
||
21 | phpinfo(); |
||
22 | exit; |
||
0 ignored issues
–
show
|
|||
23 | // @codeCoverageIgnoreEnd |
||
24 | } |
||
25 | } |
||
26 |
For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example: