These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php declare(strict_types = 1); |
||
2 | |||
3 | namespace ApiClients\Tools\Installer; |
||
4 | |||
5 | use PackageVersions\Versions; |
||
6 | use Symfony\Component\Console\Application; |
||
7 | use Symfony\Component\Console\Input\ArgvInput; |
||
8 | use Symfony\Component\Console\Output\ConsoleOutput; |
||
9 | use Symfony\Component\Yaml\Yaml; |
||
10 | use Throwable; |
||
11 | |||
12 | final class Installer |
||
13 | { |
||
14 | const TITLE = 'PHP API Clients Middleware skeleton installer'; |
||
15 | |||
16 | public static function postCreateProject() |
||
17 | { |
||
18 | try |
||
19 | { |
||
20 | $yaml = Yaml::parse( |
||
21 | file_get_contents( |
||
22 | dirname(dirname(dirname(dirname(__DIR__)))) . DIRECTORY_SEPARATOR . 'installer.yaml' |
||
23 | ) |
||
24 | ); |
||
25 | var_export($yaml); |
||
26 | die(); |
||
27 | $app = new Application( |
||
0 ignored issues
–
show
|
|||
28 | self::TITLE, |
||
29 | Versions::getVersion('api-clients/middleware-skeleton') |
||
30 | ); |
||
31 | $app->add(new Install(Install::COMMAND)); |
||
32 | $app->find(Install::COMMAND)->run(new ArgvInput([]), new ConsoleOutput()); |
||
33 | } |
||
34 | catch (Throwable $throwable) |
||
35 | { |
||
36 | echo get_class($throwable), ' thrown with message: ', $throwable->getMessage(), PHP_EOL; |
||
37 | echo $throwable->getTraceAsString(), PHP_EOL; |
||
38 | exit(1); |
||
39 | } |
||
40 | } |
||
41 | } |
This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.
Unreachable code is most often the result of
return
,die
orexit
statements that have been added for debug purposes.In the above example, the last
return false
will never be executed, because a return statement has already been met in every possible execution path.