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(); |
||
0 ignored issues
–
show
|
|||
27 | $app = new Application( |
||
0 ignored issues
–
show
$app = new \Symfony\Comp...middleware-skeleton')); does not seem to be reachable.
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 function fx() {
try {
doSomething();
return true;
}
catch (\Exception $e) {
return false;
}
return false;
}
In the above example, the last
Loading history...
|
|||
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 | } |
An exit expression should only be used in rare cases. For example, if you write a short command line script.
In most cases however, using an
exit
expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.