| Conditions | 5 |
| Paths | 1 |
| Total Lines | 71 |
| Code Lines | 49 |
| 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 |
||
| 113 | public function execute(InputInterface $input, OutputInterface $output): int |
||
| 114 | { |
||
| 115 | $target_php_settings = TargetPhpSettings::fromConsoleInput($input); |
||
| 116 | $loop_settings = TraceLoopSettings::fromConsoleInput($input); |
||
| 117 | $get_trace_settings = GetTraceSettings::fromConsoleInput($input); |
||
| 118 | $daemon_settings = DaemonSettings::fromConsoleInput($input); |
||
| 119 | |||
| 120 | $searcher_context = $this->php_searcher_context_creator->create(); |
||
| 121 | Promise\wait($searcher_context->start()); |
||
| 122 | Promise\wait($searcher_context->sendTargetRegex($daemon_settings->target_regex)); |
||
| 123 | |||
| 124 | $worker_pool = WorkerPool::create( |
||
| 125 | $this->php_reader_context_creator, |
||
| 126 | $daemon_settings->threads, |
||
| 127 | $target_php_settings, |
||
| 128 | $loop_settings, |
||
| 129 | $get_trace_settings |
||
| 130 | ); |
||
| 131 | |||
| 132 | $dispatch_table = new DispatchTable( |
||
| 133 | $worker_pool, |
||
| 134 | $target_php_settings, |
||
| 135 | $loop_settings, |
||
| 136 | $get_trace_settings |
||
| 137 | ); |
||
| 138 | |||
| 139 | exec('stty -icanon -echo'); |
||
| 140 | |||
| 141 | Loop::run(function () use ($dispatch_table, $searcher_context, $worker_pool, $output) { |
||
| 142 | Loop::onReadable( |
||
| 143 | STDIN, |
||
| 144 | /** @param resource $stream */ |
||
| 145 | function (string $watcher_id, $stream) { |
||
| 146 | $key = fread($stream, 1); |
||
| 147 | if ($key === 'q') { |
||
| 148 | Loop::cancel($watcher_id); |
||
| 149 | Loop::stop(); |
||
| 150 | } |
||
| 151 | } |
||
| 152 | ); |
||
| 153 | Loop::repeat(10, function () use ($dispatch_table, $searcher_context, $worker_pool, $output) { |
||
| 154 | $promises = []; |
||
| 155 | static $searcher_on_read = false; |
||
| 156 | if (!$searcher_on_read) { |
||
| 157 | $promises[] = \Amp\call(function () use ($searcher_context, $dispatch_table, &$searcher_on_read) { |
||
| 158 | $searcher_on_read = true; |
||
| 159 | $update_target_message = yield $searcher_context->receivePidList(); |
||
| 160 | $dispatch_table->updateTargets($update_target_message->target_process_list); |
||
| 161 | $searcher_on_read = false; |
||
| 162 | }); |
||
| 163 | } |
||
| 164 | $readers = $worker_pool->getReadableWorkers(); |
||
| 165 | foreach ($readers as $pid => $reader) { |
||
| 166 | $promises[] = \Amp\call( |
||
| 167 | function () use ($reader, $pid, $worker_pool, $dispatch_table, $output) { |
||
| 168 | $worker_pool->setOnRead($pid); |
||
| 169 | $result = yield $reader->receiveTrace(); |
||
| 170 | $worker_pool->releaseOnRead($pid); |
||
| 171 | if ($result instanceof TraceMessage) { |
||
| 172 | $output->write($result->trace); |
||
| 173 | } else { |
||
| 174 | $dispatch_table->releaseOne($result->pid); |
||
| 175 | } |
||
| 176 | } |
||
| 177 | ); |
||
| 178 | } |
||
| 179 | yield $promises; |
||
| 180 | }); |
||
| 181 | }); |
||
| 182 | |||
| 183 | return 0; |
||
| 184 | } |
||
| 186 |
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