| Conditions | 5 |
| Paths | 2 |
| Total Lines | 54 |
| Code Lines | 32 |
| 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 |
||
| 36 | public function execute(InputInterface $input, OutputInterface $output): int |
||
| 37 | { |
||
| 38 | $context = Context\create(__DIR__ . '/Worker/php-searcher.php'); |
||
| 39 | /** @var int $searcher_pid */ |
||
| 40 | $searcher_pid = Promise\wait($context->start()); |
||
| 41 | /** @var int[] $pid_list */ |
||
| 42 | $pid_list = Promise\wait($context->receive()); |
||
| 43 | $readers = []; |
||
| 44 | foreach ($pid_list as $pid) { |
||
| 45 | $context = Context\create(__DIR__ . '/Worker/php-reader.php'); |
||
| 46 | Promise\wait($context->start()); |
||
| 47 | Promise\wait($context->send($pid)); |
||
| 48 | $readers[$pid] = $context; |
||
| 49 | } |
||
| 50 | exec('stty -icanon -echo'); |
||
| 51 | |||
| 52 | Loop::run(function () use (&$readers, $output) { |
||
| 53 | Loop::onReadable( |
||
| 54 | STDIN, |
||
| 55 | /** @param resource $stream */ |
||
| 56 | function (string $watcher_id, $stream) { |
||
| 57 | $key = fread($stream, 1); |
||
| 58 | if ($key === 'q') { |
||
| 59 | Loop::cancel($watcher_id); |
||
| 60 | Loop::stop(); |
||
| 61 | } |
||
| 62 | } |
||
| 63 | ); |
||
| 64 | Loop::repeat(10, function () use (&$readers, $output) { |
||
| 65 | /** @var array<int, Context\Context> $readers */ |
||
| 66 | |||
| 67 | $promises = []; |
||
| 68 | foreach ($readers as $pid => $reader) { |
||
| 69 | if (!$reader->isRunning()) { |
||
| 70 | /** @psalm-suppress MixedArrayAccess*/ |
||
| 71 | unset($readers[$pid]); |
||
| 72 | continue; |
||
| 73 | } |
||
| 74 | $promises[] = \Amp\call( |
||
| 75 | function () use ($reader, &$readers, $pid, $output) { |
||
| 76 | /** @psalm-suppress MixedArrayAccess*/ |
||
| 77 | unset($readers[$pid]); |
||
| 78 | /** @var string $result */ |
||
| 79 | $result = yield $reader->receive(); |
||
| 80 | $output->write($result); |
||
| 81 | $readers[$pid] = $reader; |
||
| 82 | } |
||
| 83 | ); |
||
| 84 | } |
||
| 85 | yield $promises; |
||
| 86 | }); |
||
| 87 | }); |
||
| 88 | |||
| 89 | return 0; |
||
| 90 | } |
||
| 92 |
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