1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of the sj-i/php-profiler package. |
5
|
|
|
* |
6
|
|
|
* (c) sji <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
declare(strict_types=1); |
13
|
|
|
|
14
|
|
|
namespace PhpProfiler\Command\Inspector\Settings; |
15
|
|
|
|
16
|
|
|
use PhpProfiler\Command\CommandSettingsException; |
17
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
|
|
|
18
|
|
|
|
19
|
|
|
final class TraceLoopSettings |
20
|
|
|
{ |
21
|
|
|
private const SLEEP_NANO_SECONDS_DEFAULT = 1000 * 1000 * 10; |
22
|
|
|
private const CANCEL_KEY_DEFAULT = 'q'; |
23
|
|
|
private const MAX_RETRY_DEFAULT = -1; |
24
|
|
|
|
25
|
|
|
public int $sleep_nano_seconds; |
26
|
|
|
public string $cancel_key; |
27
|
|
|
public int $max_retries; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* TraceLoopSettings constructor. |
31
|
|
|
* @param int $sleep_nano_seconds |
32
|
|
|
* @param string $cancel_key |
33
|
|
|
* @param int $max_retries |
34
|
|
|
*/ |
35
|
|
|
public function __construct(int $sleep_nano_seconds, string $cancel_key, int $max_retries) |
36
|
|
|
{ |
37
|
|
|
$this->sleep_nano_seconds = $sleep_nano_seconds; |
38
|
|
|
$this->cancel_key = $cancel_key; |
39
|
|
|
$this->max_retries = $max_retries; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @param InputInterface $input |
44
|
|
|
* @return self |
45
|
|
|
* @throws CommandSettingsException |
46
|
|
|
*/ |
47
|
|
|
public static function fromConsoleInput(InputInterface $input): self |
48
|
|
|
{ |
49
|
|
|
$sleep_nano_seconds = $input->getOption('sleep-ns'); |
50
|
|
|
if (is_null($sleep_nano_seconds)) { |
51
|
|
|
$sleep_nano_seconds = self::SLEEP_NANO_SECONDS_DEFAULT; |
52
|
|
|
} |
53
|
|
|
$sleep_nano_seconds = filter_var($sleep_nano_seconds, FILTER_VALIDATE_INT); |
54
|
|
|
if ($sleep_nano_seconds === false) { |
55
|
|
|
throw TraceLoopSettingsException::create(TraceLoopSettingsException::SLEEP_NS_IS_NOT_INTEGER); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
$max_retries = $input->getOption('max-retries'); |
59
|
|
|
if (is_null($max_retries)) { |
60
|
|
|
$max_retries = self::MAX_RETRY_DEFAULT; |
61
|
|
|
} |
62
|
|
|
$max_retries = filter_var($max_retries, FILTER_VALIDATE_INT); |
63
|
|
|
if ($max_retries === false) { |
64
|
|
|
throw TraceLoopSettingsException::create(TraceLoopSettingsException::MAX_RETRY_IS_NOT_INTEGER); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
return new self($sleep_nano_seconds, self::CANCEL_KEY_DEFAULT, $max_retries); |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|
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