| Conditions | 5 |
| Paths | 2 |
| Total Lines | 61 |
| Code Lines | 37 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 4 | ||
| Bugs | 0 | Features | 1 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 90 | public function execute(InputInterface $input, OutputInterface $output): int |
||
| 91 | { |
||
| 92 | $target_php_settings = TargetPhpSettings::fromConsoleInput($input); |
||
| 93 | $loop_settings = TraceLoopSettings::fromConsoleInput($input); |
||
| 94 | $get_trace_settings = GetTraceSettings::fromConsoleInput($input); |
||
| 95 | |||
| 96 | /** @var string $target_regex */ |
||
| 97 | $target_regex = '{' . ($input->getOption('target-regex') ?? '^php-fpm') . '}'; |
||
| 98 | $context = Context\create(__DIR__ . '/Worker/php-searcher.php'); |
||
| 99 | /** @var int $searcher_pid */ |
||
| 100 | $searcher_pid = Promise\wait($context->start()); |
||
| 101 | Promise\wait($context->send($target_regex)); |
||
| 102 | /** @var int[] $pid_list */ |
||
| 103 | $pid_list = Promise\wait($context->receive()); |
||
| 104 | $readers = []; |
||
| 105 | foreach ($pid_list as $target_pid) { |
||
| 106 | $context = Context\create(__DIR__ . '/Worker/php-reader.php'); |
||
| 107 | Promise\wait($context->start()); |
||
| 108 | Promise\wait($context->send([$target_pid, $target_php_settings, $loop_settings, $get_trace_settings])); |
||
| 109 | $readers[$target_pid] = $context; |
||
| 110 | } |
||
| 111 | exec('stty -icanon -echo'); |
||
| 112 | |||
| 113 | Loop::run(function () use (&$readers, $output) { |
||
| 114 | Loop::onReadable( |
||
| 115 | STDIN, |
||
| 116 | /** @param resource $stream */ |
||
| 117 | function (string $watcher_id, $stream) { |
||
| 118 | $key = fread($stream, 1); |
||
| 119 | if ($key === 'q') { |
||
| 120 | Loop::cancel($watcher_id); |
||
| 121 | Loop::stop(); |
||
| 122 | } |
||
| 123 | } |
||
| 124 | ); |
||
| 125 | Loop::repeat(10, function () use (&$readers, $output) { |
||
| 126 | /** @var array<int, Context\Context> $readers */ |
||
| 127 | |||
| 128 | $promises = []; |
||
| 129 | foreach ($readers as $pid => $reader) { |
||
| 130 | if (!$reader->isRunning()) { |
||
| 131 | /** @psalm-suppress MixedArrayAccess*/ |
||
| 132 | unset($readers[$pid]); |
||
| 133 | continue; |
||
| 134 | } |
||
| 135 | $promises[] = \Amp\call( |
||
| 136 | function () use ($reader, &$readers, $pid, $output) { |
||
| 137 | /** @psalm-suppress MixedArrayAccess*/ |
||
| 138 | unset($readers[$pid]); |
||
| 139 | /** @var string $result */ |
||
| 140 | $result = yield $reader->receive(); |
||
| 141 | $output->write($result); |
||
| 142 | $readers[$pid] = $reader; |
||
| 143 | } |
||
| 144 | ); |
||
| 145 | } |
||
| 146 | yield $promises; |
||
| 147 | }); |
||
| 148 | }); |
||
| 149 | |||
| 150 | return 0; |
||
| 151 | } |
||
| 153 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths