Conditions | 14 |
Paths | 32 |
Total Lines | 64 |
Code Lines | 47 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 2 |
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 |
||
75 | public function execute(InputInterface $input, OutputInterface $output): int |
||
76 | { |
||
77 | $pid = $input->getOption('pid'); |
||
78 | if (is_null($pid)) { |
||
79 | $error_output = $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output; |
||
80 | $error_output->writeln('pid is not specified'); |
||
81 | return 1; |
||
82 | } |
||
83 | $pid = filter_var($pid, FILTER_VALIDATE_INT); |
||
84 | if ($pid === false) { |
||
85 | $error_output = $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output; |
||
86 | $error_output->writeln('pid is not integer'); |
||
87 | return 2; |
||
88 | } |
||
89 | |||
90 | $depth = $input->getOption('depth'); |
||
91 | if (is_null($depth)) { |
||
92 | $depth = PHP_INT_MAX; |
||
93 | } |
||
94 | $depth = filter_var($depth, FILTER_VALIDATE_INT); |
||
95 | if ($depth === false) { |
||
96 | $error_output = $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output; |
||
97 | $error_output->writeln('depth is not integer'); |
||
98 | return 2; |
||
99 | } |
||
100 | |||
101 | $sleep_nano_seconds = $input->getOption('sleep-ns'); |
||
102 | if (is_null($sleep_nano_seconds)) { |
||
103 | $sleep_nano_seconds = self::SLEEP_NANO_SECONDS_DEFAULT; |
||
104 | } |
||
105 | $sleep_nano_seconds = filter_var($sleep_nano_seconds, FILTER_VALIDATE_INT); |
||
106 | if ($sleep_nano_seconds === false) { |
||
107 | $error_output = $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output; |
||
108 | $error_output->writeln('sleep-ns is not integer'); |
||
109 | return 2; |
||
110 | } |
||
111 | |||
112 | $eg_address = $this->php_globals_finder->findExecutorGlobals($pid); |
||
113 | |||
114 | exec('stty -icanon -echo'); |
||
115 | $keyboard_input = fopen('php://stdin', 'r'); |
||
116 | stream_set_blocking($keyboard_input, false); |
||
117 | |||
118 | $key = ''; |
||
119 | $count_retry = 0; |
||
120 | while ($key !== 'q' and $count_retry < 10) { |
||
121 | try { |
||
122 | echo join( |
||
123 | PHP_EOL, |
||
124 | $this->executor_globals_reader->readCallTrace( |
||
125 | $pid, |
||
126 | $eg_address, |
||
127 | $depth |
||
128 | ) |
||
129 | ) , PHP_EOL, PHP_EOL; |
||
130 | $count_retry = 0; |
||
131 | time_nanosleep(0, $sleep_nano_seconds); |
||
132 | } catch (MemoryReaderException $e) { |
||
133 | $count_retry++; |
||
134 | } |
||
135 | $key = fread($keyboard_input, 1); |
||
136 | } |
||
137 | |||
138 | return 0; |
||
139 | } |
||
141 |
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