25 | */
26 | class PhpProcess extends Process
27 | {
28 | /**
29 | * @param string $script The PHP script to run (as a string)
30 | * @param string|null $cwd The working directory or null to use the working dir of the current PHP process
31 | * @param array|null $env The environment variables or null to use the same environment as the current PHP process
32 | * @param int $timeout The timeout in seconds
33 | * @param array|null $php Path to the PHP binary to use with any additional arguments
34 | */
35 | public function __construct(string $script, ?string $cwd = null, ?array $env = null, int $timeout = 60, ?array $php = null)
36 | {
37 | if (null === $php) {
38 | $executableFinder = new PhpExecutableFinder();
39 | $php = $executableFinder->find(false);
40 | $php = false === $php ? null : array_merge([$php], $executableFinder->findArguments());
41 | }
42 | if ('phpdbg' === \PHP_SAPI) {
43 | $file = tempnam(sys_get_temp_dir(), 'dbg');
44 | file_put_contents($file, $script);
45 | register_shutdown_function('unlink', $file);
46 | $php[] = $file;
47 | $script = null;
48 | }
49 |
50 | parent::__construct($php, $cwd, $env, $script, $timeout);
51 | }
52 |
53 | /**
54 | * {@inheritdoc}
55 | */
56 | public static function fromShellCommandline(string $command, ?string $cwd = null, ?array $env = null, $input = null, ?float $timeout = 60)
57 | {
58 | throw new LogicException(sprintf('The "%s()" method cannot be called when using "%s".', __METHOD__, self::class));
59 | }
60 |
61 | /**
62 | * {@inheritdoc}
63 | */
64 | public function start(?callable $callback = null, array $env = [])
65 | {
66 | if (null === $this->getCommandLine()) {
67 | throw new RuntimeException('Unable to find the PHP executable.');
68 | }
69 |
70 | parent::start($callback, $env);
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/lang/cs.json:
--------------------------------------------------------------------------------
1 | {
2 | "PerformanceAudit": {
3 | "BrowserFamilies": "Rodiny prohlížečů",
4 | "Category": "Výkon",
5 | "CoreAdminHome_MenuPerformance": "Výkon",
6 | "CoreAdminHome_PluginPerformance": "Zásuvný modul PerformanceAudit",
7 | "CoreAdminHome_VersionPerformance": "V současné době používáte verzi %1$s%2$s%3$s zásuvného modulu %4$s.",
8 | "Donate_BuyMeACoffee": "Kupte mi kávu",
9 | "EnvironmentDesktop": "desktop",
10 | "EnvironmentMobile": "mobil",
11 | "Metrics_Max_Percent": "Nejvyšší %",
12 | "Metrics_Max_Percent_Documentation": "Maximální procento, kterého stránka dosáhla v této výkonnostní kategorii.",
13 | "Metrics_Max_Seconds": "Max. Sekundy",
14 | "Metrics_Max_Seconds_Documentation": "Horní hranice v sekundách, kterou stránka zabrala v této výkonnostní kategorii.",
15 | "Metrics_Median_Percent": "Median %",
16 | "Metrics_Median_Percent_Documentation": "Celkový medián procent, kterého stránka dosáhla v této výkonnostní kategorii.",
17 | "Metrics_Median_Seconds": "Median Sekund",
18 | "Metrics_Median_Seconds_Documentation": "Celkový medián v sekundách, který stránka v této kategorii výkonu potřebovala.",
19 | "Metrics_Min_Percent": "Nejnižší %",
20 | "Metrics_Min_Percent_Documentation": "Minimální procento, kterého stránka dosáhla v této výkonnostní kategorii.",
21 | "Metrics_Min_Seconds": "Min. Sekundy",
22 | "Metrics_Min_Seconds_Documentation": "Spodní hranice v sekundách, kterou stránka v této výkonnostní kategorii zabrala.",
23 | "Metrics_Tooltip": "%1$s%2$s je klasifikováno jako %3$s! \n Do této klasifikační skupiny patří hodnoty v rozmezí %4$s%2$s - %5$s%2$s.",
24 | "Metrics_Tooltip_OutOfRange": "%1$s%2$s je mimo rozsah všech klasifikačních skupin.",
25 | "MobileOverview": "Přehled mobilních zařízení",
26 | "Overview": "Přehled výkonu",
27 | "PluginCheck": "Kontrola pluginu",
28 | "PluginCheckAlertNoSystemIssues": "Všechny předběžné kontroly pluginů proběhly úspěšně, nevyskytly se žádné chyby. Nyní můžete spustit vlastní kontrolu zásuvného modulu kliknutím na následující tlačítko:",
29 | "PluginCheckAlertSystemIssue": "Ve vašem systému je problém. Došlo k následující chybě:",
30 | "PluginCheckHasErrors": "Ve vašem systému jsou určité problémy. Matomo bude spuštěn, ale mohou se vyskytnout problémy s tímto pluginem. Další informace naleznete níže.",
31 | "PluginCheckLogOutput": "Výstup protokolu",
32 | "PluginCheckStartButton": "Spuštění kontroly pluginů",
33 | "PluginCheckStartButtonClicked": "Kontrola pluginu byla zahájena, vyčkejte prosím až 5 minut…",
34 | "Report_CumulativeLayoutShift_Documentation_Information": "kumulativní posun rozložení"
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/vendor/symfony/process/InputStream.php:
--------------------------------------------------------------------------------
1 |
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 | namespace Symfony\Component\Process;
13 |
14 | use Symfony\Component\Process\Exception\RuntimeException;
15 |
16 | /**
17 | * Provides a way to continuously write to the input of a Process until the InputStream is closed.
18 | *
19 | * @author Nicolas Grekas
20 | *
21 | * @implements \IteratorAggregate
22 | */
23 | class InputStream implements \IteratorAggregate
24 | {
25 | /** @var callable|null */
26 | private $onEmpty = null;
27 | private $input = [];
28 | private $open = true;
29 |
30 | /**
31 | * Sets a callback that is called when the write buffer becomes empty.
32 | */
33 | public function onEmpty(?callable $onEmpty = null)
34 | {
35 | $this->onEmpty = $onEmpty;
36 | }
37 |
38 | /**
39 | * Appends an input to the write buffer.
40 | *
41 | * @param resource|string|int|float|bool|\Traversable|null $input The input to append as scalar,
42 | * stream resource or \Traversable
43 | */
44 | public function write($input)
45 | {
46 | if (null === $input) {
47 | return;
48 | }
49 | if ($this->isClosed()) {
50 | throw new RuntimeException(sprintf('"%s" is closed.', static::class));
51 | }
52 | $this->input[] = ProcessUtils::validateInput(__METHOD__, $input);
53 | }
54 |
55 | /**
56 | * Closes the write buffer.
57 | */
58 | public function close()
59 | {
60 | $this->open = false;
61 | }
62 |
63 | /**
64 | * Tells whether the write buffer is closed or not.
65 | */
66 | public function isClosed()
67 | {
68 | return !$this->open;
69 | }
70 |
71 | /**
72 | * @return \Traversable
73 | */
74 | #[\ReturnTypeWillChange]
75 | public function getIterator()
76 | {
77 | $this->open = true;
78 |
79 | while ($this->open || $this->input) {
80 | if (!$this->input) {
81 | yield '';
82 | continue;
83 | }
84 | $current = array_shift($this->input);
85 |
86 | if ($current instanceof \Iterator) {
87 | yield from $current;
88 | } else {
89 | yield $current;
90 | }
91 | if (!$this->input && $this->open && null !== $onEmpty = $this->onEmpty) {
92 | $this->write($onEmpty($this));
93 | }
94 | }
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/vendor/composer/installed.php:
--------------------------------------------------------------------------------
1 | array(
3 | 'name' => 'devdavido/performance-audit-plugin',
4 | 'pretty_version' => 'dev-5.x-dev',
5 | 'version' => 'dev-5.x-dev',
6 | 'reference' => 'acaa1139e1ede76ca25cafe7e30e0ff3abfd1cd8',
7 | 'type' => 'project',
8 | 'install_path' => __DIR__ . '/../../',
9 | 'aliases' => array(),
10 | 'dev' => false,
11 | ),
12 | 'versions' => array(
13 | 'devdavido/lighthouse' => array(
14 | 'pretty_version' => 'dev-master',
15 | 'version' => 'dev-master',
16 | 'reference' => '91ddfe4126453d3c9cb4c8263a5238967fbdf9ac',
17 | 'type' => 'library',
18 | 'install_path' => __DIR__ . '/../devdavido/lighthouse',
19 | 'aliases' => array(
20 | 0 => '9999999-dev',
21 | ),
22 | 'dev_requirement' => false,
23 | ),
24 | 'devdavido/performance-audit-plugin' => array(
25 | 'pretty_version' => 'dev-5.x-dev',
26 | 'version' => 'dev-5.x-dev',
27 | 'reference' => 'acaa1139e1ede76ca25cafe7e30e0ff3abfd1cd8',
28 | 'type' => 'project',
29 | 'install_path' => __DIR__ . '/../../',
30 | 'aliases' => array(),
31 | 'dev_requirement' => false,
32 | ),
33 | 'ducks-project/spl-types' => array(
34 | 'pretty_version' => 'v5.0.0',
35 | 'version' => '5.0.0.0',
36 | 'reference' => '15093fc875ddd8bb1e14d009445b7e7fafa1a42e',
37 | 'type' => 'library',
38 | 'install_path' => __DIR__ . '/../ducks-project/spl-types',
39 | 'aliases' => array(),
40 | 'dev_requirement' => false,
41 | ),
42 | 'symfony/polyfill-mbstring' => array(
43 | 'pretty_version' => 'v1.31.0',
44 | 'version' => '1.31.0.0',
45 | 'reference' => '85181ba99b2345b0ef10ce42ecac37612d9fd341',
46 | 'type' => 'library',
47 | 'install_path' => __DIR__ . '/../symfony/polyfill-mbstring',
48 | 'aliases' => array(),
49 | 'dev_requirement' => false,
50 | ),
51 | 'symfony/polyfill-php80' => array(
52 | 'pretty_version' => 'v1.31.0',
53 | 'version' => '1.31.0.0',
54 | 'reference' => '60328e362d4c2c802a54fcbf04f9d3fb892b4cf8',
55 | 'type' => 'library',
56 | 'install_path' => __DIR__ . '/../symfony/polyfill-php80',
57 | 'aliases' => array(),
58 | 'dev_requirement' => false,
59 | ),
60 | 'symfony/process' => array(
61 | 'pretty_version' => 'v5.4.46',
62 | 'version' => '5.4.46.0',
63 | 'reference' => '01906871cb9b5e3cf872863b91aba4ec9767daf4',
64 | 'type' => 'library',
65 | 'install_path' => __DIR__ . '/../symfony/process',
66 | 'aliases' => array(),
67 | 'dev_requirement' => false,
68 | ),
69 | ),
70 | );
71 |
--------------------------------------------------------------------------------
/vendor/ducks-project/spl-types/.php-cs-fixer.dist.php:
--------------------------------------------------------------------------------
1 | setRiskyAllowed(true)
5 | ->setRules([
6 | '@PSR12' => true,
7 | '@PHP74Migration:risky' => true,
8 | '@PHP80Migration' => true,
9 | 'binary_operator_spaces' => true,
10 | 'cast_spaces' => ['space' => 'single'],
11 | 'concat_space' => ['spacing' => 'one'],
12 | 'declare_strict_types' => false,
13 | 'empty_loop_body' => ['style' => 'semicolon'],
14 | 'empty_loop_condition' => ['style' => 'while'],
15 | 'fully_qualified_strict_types' => true,
16 | 'function_typehint_space' => true,
17 | 'include' => true,
18 | 'lambda_not_used_import' => true,
19 | 'linebreak_after_opening_tag' => true,
20 | 'magic_constant_casing' => true,
21 | 'magic_method_casing' => true,
22 | 'native_function_casing' => true,
23 | 'native_function_type_declaration_casing' => true,
24 | 'no_alias_language_construct_call' => true,
25 | 'no_blank_lines_after_phpdoc' => true,
26 | 'no_empty_comment' => true,
27 | 'no_empty_phpdoc' => true,
28 | 'no_empty_statement' => true,
29 | 'no_extra_blank_lines' => true,
30 | 'no_leading_namespace_whitespace' => true,
31 | 'no_mixed_echo_print' => true,
32 | 'no_multiline_whitespace_around_double_arrow' => true,
33 | 'no_singleline_whitespace_before_semicolons' => true,
34 | 'no_spaces_around_offset' => true,
35 | 'no_trailing_comma_in_list_call' => true,
36 | 'no_trailing_comma_in_singleline' => true,
37 | 'no_unneeded_control_parentheses' => ['statements' => ['break', 'clone', 'continue', 'return', 'switch_case', 'yield']],
38 | 'no_unneeded_curly_braces' => true,
39 | 'no_unneeded_import_alias' => true,
40 | 'no_unused_imports' => true,
41 | 'object_operator_without_whitespace' => true,
42 | 'phpdoc_align' => ['align' => 'left'],
43 | 'phpdoc_indent' => true,
44 | 'phpdoc_inline_tag_normalizer' => true,
45 | 'phpdoc_no_access' => true,
46 | 'phpdoc_no_package' => true,
47 | 'phpdoc_return_self_reference' => true,
48 | 'phpdoc_scalar' => true,
49 | 'phpdoc_separation' => true,
50 | 'phpdoc_single_line_var_spacing' => true,
51 | 'phpdoc_summary' => true,
52 | 'phpdoc_trim' => true,
53 | 'phpdoc_trim_consecutive_blank_line_separation' => true,
54 | 'phpdoc_types' => true,
55 | 'semicolon_after_instruction' => true,
56 | 'single_line_comment_spacing' => true,
57 | 'single_space_after_construct' => true,
58 | 'space_after_semicolon' => true,
59 | 'standardize_increment' => true,
60 | 'standardize_not_equals' => true,
61 | 'trim_array_spaces' => true,
62 | 'unary_operator_spaces' => true,
63 | 'whitespace_after_comma_in_array' => true,
64 | 'yoda_style' => true,
65 | ])
66 | ->setFinder(
67 | PhpCsFixer\Finder::create()
68 | // ->exclude('folder-to-exclude') // if you want to exclude some folders, you can do it like this!
69 | ->in(__DIR__)
70 | )
71 | ;
72 |
--------------------------------------------------------------------------------
/ExecutableFinder.php:
--------------------------------------------------------------------------------
1 | debug('Searching for executable in directories.',
34 | ['executable' => $name, 'directories' => $extraDirs]);
35 |
36 | $executablePath = (new parent())->find($name, false, $extraDirs);
37 | if (!$executablePath) {
38 | throw new DependencyMissingException($name, $extraDirs);
39 | }
40 |
41 | return $executablePath;
42 | }
43 |
44 | /**
45 | * Get default path for executables depending on platform.
46 | *
47 | * @return string
48 | */
49 | public static function getDefaultPath() {
50 | $searchPaths = ExecutableFinder::isRunningOnWindows() ? [
51 | '%SystemRoot%\system32',
52 | '%SystemRoot%',
53 | '%SystemRoot%\System32\Wbem'
54 | ] : [
55 | '/usr/local/sbin',
56 | '/usr/local/bin',
57 | '/usr/sbin',
58 | '/usr/bin',
59 | '/sbin',
60 | '/bin',
61 | '/opt/plesk/node/24/bin',
62 | '/opt/plesk/node/22/bin',
63 | '/opt/plesk/node/20/bin',
64 | '/opt/plesk/node/18/bin',
65 | '/opt/plesk/node/16/bin',
66 | '/opt/plesk/node/14/bin',
67 | '/opt/plesk/node/12/bin',
68 | '/opt/plesk/node/10/bin'
69 | ];
70 | $additionalSearchPaths = ExecutableFinder::getPathsFromEnvironmentVariablePath();
71 | $finalSearchPaths = array_unique(array_merge($searchPaths, $additionalSearchPaths));
72 |
73 | return implode(PATH_SEPARATOR, $finalSearchPaths);
74 | }
75 |
76 | /**
77 | * Return paths as array if `PATH` environment variable is set,
78 | * empty array otherwise.
79 | *
80 | * @return array
81 | */
82 | private static function getPathsFromEnvironmentVariablePath() {
83 | $envPath = getenv('PATH');
84 | if (!is_string($envPath)) {
85 | return [];
86 | }
87 |
88 | return explode(PATH_SEPARATOR, $envPath);
89 | }
90 |
91 | /**
92 | * Check if running on MS Windows.
93 | *
94 | * @return bool
95 | */
96 | public static function isRunningOnWindows()
97 | {
98 | return strtoupper(substr(PHP_OS, 0, 3)) === 'WIN';
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/Columns/Filters/AuditScoreClassifier.php:
--------------------------------------------------------------------------------
1 | [
18 | 'slow' => [0, 50],
19 | 'moderate' => [50, 90],
20 | 'fast' => [90, 100]
21 | ],
22 | 'firstContentfulPaint' => [
23 | 'fast' => [0, 2],
24 | 'moderate' => [2, 4],
25 | 'slow' => [4, 60]
26 | ],
27 | 'speedIndex' => [
28 | 'fast' => [0, 4.4],
29 | 'moderate' => [4.4, 5.8],
30 | 'slow' => [5.8, 60]
31 | ],
32 | 'largestContentfulPaint' => [
33 | 'fast' => [0, 2.5],
34 | 'moderate' => [2.5, 4.0],
35 | 'slow' => [4.0, 60]
36 | ],
37 | 'interactive' => [
38 | 'fast' => [0, 3.8],
39 | 'moderate' => [3.8, 7.3],
40 | 'slow' => [7.3, 60]
41 | ],
42 | 'totalBlockingTime' => [
43 | 'fast' => [0, 0.3],
44 | 'moderate' => [0.3, 0.6],
45 | 'slow' => [0.6, 10]
46 | ],
47 | 'cumulativeLayoutShift' => [
48 | 'fast' => [0, 0.1],
49 | 'moderate' => [0.1, 0.25],
50 | 'slow' => [0.25, 10]
51 | ]
52 | ];
53 |
54 | /**
55 | * Return tooltip string.
56 | *
57 | * @param string $metric
58 | * @param string $dataTableName
59 | * @return string
60 | */
61 | public static function getTooltip(string $metric, string $dataTableName)
62 | {
63 | $isUnitPercent = mb_strstr($dataTableName, '_Score_');
64 | $unitSuffix = ($isUnitPercent) ? '%' : 's';
65 | $value = str_replace($unitSuffix, '', $metric);
66 |
67 | if (!is_numeric($value)) {
68 | return '';
69 | }
70 |
71 | preg_match('/((.*)_){2}(.*)_/', $dataTableName, $matches);
72 | $metricCategory = lcfirst($matches[3]);
73 | $ranges = self::RANGES[$metricCategory];
74 |
75 | foreach ($ranges as $classification => $boundaries) {
76 | $lowerBoundary = $boundaries[0];
77 | $upperBoundary = $boundaries[1];
78 | $isLastBoundary = $boundaries === end($ranges);
79 | if (self::isInRange($value, $lowerBoundary, $upperBoundary, $isLastBoundary)) {
80 | return nl2br(Piwik::translate('PerformanceAudit_Metrics_Tooltip', [
81 | $value,
82 | $unitSuffix,
83 | mb_strtoupper($classification),
84 | $lowerBoundary,
85 | $upperBoundary,
86 | ]), true);
87 | }
88 | }
89 |
90 | return Piwik::translate('PerformanceAudit_Metrics_Tooltip_OutOfRange', [$value, $unitSuffix]);
91 | }
92 |
93 | /**
94 | * Checks if number is within range.
95 | *
96 | * @param float|int $value
97 | * @param float $lowerBoundary
98 | * @param float $upperBoundary
99 | * @param bool $includingEqualUpperBound
100 | * @return bool
101 | */
102 | private static function isInRange($value, float $lowerBoundary, float $upperBoundary, bool $includingEqualUpperBound = true)
103 | {
104 | return ($lowerBoundary <= $value) && (($includingEqualUpperBound) ? ($value <= $upperBoundary) : ($value < $upperBoundary));
105 | }
106 | }
107 |
--------------------------------------------------------------------------------
/vendor/symfony/process/ExecutableFinder.php:
--------------------------------------------------------------------------------
1 |
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 | namespace Symfony\Component\Process;
13 |
14 | /**
15 | * Generic executable finder.
16 | *
17 | * @author Fabien Potencier
18 | * @author Johannes M. Schmitt
19 | */
20 | class ExecutableFinder
21 | {
22 | private const CMD_BUILTINS = [
23 | 'assoc', 'break', 'call', 'cd', 'chdir', 'cls', 'color', 'copy', 'date',
24 | 'del', 'dir', 'echo', 'endlocal', 'erase', 'exit', 'for', 'ftype', 'goto',
25 | 'help', 'if', 'label', 'md', 'mkdir', 'mklink', 'move', 'path', 'pause',
26 | 'popd', 'prompt', 'pushd', 'rd', 'rem', 'ren', 'rename', 'rmdir', 'set',
27 | 'setlocal', 'shift', 'start', 'time', 'title', 'type', 'ver', 'vol',
28 | ];
29 |
30 | private $suffixes = [];
31 |
32 | /**
33 | * Replaces default suffixes of executable.
34 | */
35 | public function setSuffixes(array $suffixes)
36 | {
37 | $this->suffixes = $suffixes;
38 | }
39 |
40 | /**
41 | * Adds new possible suffix to check for executable.
42 | */
43 | public function addSuffix(string $suffix)
44 | {
45 | $this->suffixes[] = $suffix;
46 | }
47 |
48 | /**
49 | * Finds an executable by name.
50 | *
51 | * @param string $name The executable name (without the extension)
52 | * @param string|null $default The default to return if no executable is found
53 | * @param array $extraDirs Additional dirs to check into
54 | *
55 | * @return string|null
56 | */
57 | public function find(string $name, ?string $default = null, array $extraDirs = [])
58 | {
59 | // windows built-in commands that are present in cmd.exe should not be resolved using PATH as they do not exist as exes
60 | if ('\\' === \DIRECTORY_SEPARATOR && \in_array(strtolower($name), self::CMD_BUILTINS, true)) {
61 | return $name;
62 | }
63 |
64 | $dirs = array_merge(
65 | explode(\PATH_SEPARATOR, getenv('PATH') ?: getenv('Path')),
66 | $extraDirs
67 | );
68 |
69 | $suffixes = [];
70 | if ('\\' === \DIRECTORY_SEPARATOR) {
71 | $pathExt = getenv('PATHEXT');
72 | $suffixes = $this->suffixes;
73 | $suffixes = array_merge($suffixes, $pathExt ? explode(\PATH_SEPARATOR, $pathExt) : ['.exe', '.bat', '.cmd', '.com']);
74 | }
75 | $suffixes = '' !== pathinfo($name, PATHINFO_EXTENSION) ? array_merge([''], $suffixes) : array_merge($suffixes, ['']);
76 | foreach ($suffixes as $suffix) {
77 | foreach ($dirs as $dir) {
78 | if ('' === $dir) {
79 | $dir = '.';
80 | }
81 | if (@is_file($file = $dir.\DIRECTORY_SEPARATOR.$name.$suffix) && ('\\' === \DIRECTORY_SEPARATOR || @is_executable($file))) {
82 | return $file;
83 | }
84 |
85 | if (!@is_dir($dir) && basename($dir) === $name.$suffix && @is_executable($dir)) {
86 | return $dir;
87 | }
88 | }
89 | }
90 |
91 | if ('\\' === \DIRECTORY_SEPARATOR || !\function_exists('exec') || \strlen($name) !== strcspn($name, '/'.\DIRECTORY_SEPARATOR)) {
92 | return $default;
93 | }
94 |
95 | $execResult = exec('command -v -- '.escapeshellarg($name));
96 |
97 | if (($executablePath = substr($execResult, 0, strpos($execResult, \PHP_EOL) ?: null)) && @is_executable($executablePath)) {
98 | return $executablePath;
99 | }
100 |
101 | return $default;
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/vendor/symfony/polyfill-php80/Php80.php:
--------------------------------------------------------------------------------
1 |
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 | namespace Symfony\Polyfill\Php80;
13 |
14 | /**
15 | * @author Ion Bazan
16 | * @author Nico Oelgart
17 | * @author Nicolas Grekas
18 | *
19 | * @internal
20 | */
21 | final class Php80
22 | {
23 | public static function fdiv(float $dividend, float $divisor): float
24 | {
25 | return @($dividend / $divisor);
26 | }
27 |
28 | public static function get_debug_type($value): string
29 | {
30 | switch (true) {
31 | case null === $value: return 'null';
32 | case \is_bool($value): return 'bool';
33 | case \is_string($value): return 'string';
34 | case \is_array($value): return 'array';
35 | case \is_int($value): return 'int';
36 | case \is_float($value): return 'float';
37 | case \is_object($value): break;
38 | case $value instanceof \__PHP_Incomplete_Class: return '__PHP_Incomplete_Class';
39 | default:
40 | if (null === $type = @get_resource_type($value)) {
41 | return 'unknown';
42 | }
43 |
44 | if ('Unknown' === $type) {
45 | $type = 'closed';
46 | }
47 |
48 | return "resource ($type)";
49 | }
50 |
51 | $class = \get_class($value);
52 |
53 | if (false === strpos($class, '@')) {
54 | return $class;
55 | }
56 |
57 | return (get_parent_class($class) ?: key(class_implements($class)) ?: 'class').'@anonymous';
58 | }
59 |
60 | public static function get_resource_id($res): int
61 | {
62 | if (!\is_resource($res) && null === @get_resource_type($res)) {
63 | throw new \TypeError(sprintf('Argument 1 passed to get_resource_id() must be of the type resource, %s given', get_debug_type($res)));
64 | }
65 |
66 | return (int) $res;
67 | }
68 |
69 | public static function preg_last_error_msg(): string
70 | {
71 | switch (preg_last_error()) {
72 | case \PREG_INTERNAL_ERROR:
73 | return 'Internal error';
74 | case \PREG_BAD_UTF8_ERROR:
75 | return 'Malformed UTF-8 characters, possibly incorrectly encoded';
76 | case \PREG_BAD_UTF8_OFFSET_ERROR:
77 | return 'The offset did not correspond to the beginning of a valid UTF-8 code point';
78 | case \PREG_BACKTRACK_LIMIT_ERROR:
79 | return 'Backtrack limit exhausted';
80 | case \PREG_RECURSION_LIMIT_ERROR:
81 | return 'Recursion limit exhausted';
82 | case \PREG_JIT_STACKLIMIT_ERROR:
83 | return 'JIT stack limit exhausted';
84 | case \PREG_NO_ERROR:
85 | return 'No error';
86 | default:
87 | return 'Unknown error';
88 | }
89 | }
90 |
91 | public static function str_contains(string $haystack, string $needle): bool
92 | {
93 | return '' === $needle || false !== strpos($haystack, $needle);
94 | }
95 |
96 | public static function str_starts_with(string $haystack, string $needle): bool
97 | {
98 | return 0 === strncmp($haystack, $needle, \strlen($needle));
99 | }
100 |
101 | public static function str_ends_with(string $haystack, string $needle): bool
102 | {
103 | if ('' === $needle || $needle === $haystack) {
104 | return true;
105 | }
106 |
107 | if ('' === $haystack) {
108 | return false;
109 | }
110 |
111 | $needleLength = \strlen($needle);
112 |
113 | return $needleLength <= \strlen($haystack) && 0 === substr_compare($haystack, $needle, -$needleLength);
114 | }
115 | }
116 |
--------------------------------------------------------------------------------
/vendor/symfony/process/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | CHANGELOG
2 | =========
3 |
4 | 5.2.0
5 | -----
6 |
7 | * added `Process::setOptions()` to set `Process` specific options
8 | * added option `create_new_console` to allow a subprocess to continue
9 | to run after the main script exited, both on Linux and on Windows
10 |
11 | 5.1.0
12 | -----
13 |
14 | * added `Process::getStartTime()` to retrieve the start time of the process as float
15 |
16 | 5.0.0
17 | -----
18 |
19 | * removed `Process::inheritEnvironmentVariables()`
20 | * removed `PhpProcess::setPhpBinary()`
21 | * `Process` must be instantiated with a command array, use `Process::fromShellCommandline()` when the command should be parsed by the shell
22 | * removed `Process::setCommandLine()`
23 |
24 | 4.4.0
25 | -----
26 |
27 | * deprecated `Process::inheritEnvironmentVariables()`: env variables are always inherited.
28 | * added `Process::getLastOutputTime()` method
29 |
30 | 4.2.0
31 | -----
32 |
33 | * added the `Process::fromShellCommandline()` to run commands in a shell wrapper
34 | * deprecated passing a command as string when creating a `Process` instance
35 | * deprecated the `Process::setCommandline()` and the `PhpProcess::setPhpBinary()` methods
36 | * added the `Process::waitUntil()` method to wait for the process only for a
37 | specific output, then continue the normal execution of your application
38 |
39 | 4.1.0
40 | -----
41 |
42 | * added the `Process::isTtySupported()` method that allows to check for TTY support
43 | * made `PhpExecutableFinder` look for the `PHP_BINARY` env var when searching the php binary
44 | * added the `ProcessSignaledException` class to properly catch signaled process errors
45 |
46 | 4.0.0
47 | -----
48 |
49 | * environment variables will always be inherited
50 | * added a second `array $env = []` argument to the `start()`, `run()`,
51 | `mustRun()`, and `restart()` methods of the `Process` class
52 | * added a second `array $env = []` argument to the `start()` method of the
53 | `PhpProcess` class
54 | * the `ProcessUtils::escapeArgument()` method has been removed
55 | * the `areEnvironmentVariablesInherited()`, `getOptions()`, and `setOptions()`
56 | methods of the `Process` class have been removed
57 | * support for passing `proc_open()` options has been removed
58 | * removed the `ProcessBuilder` class, use the `Process` class instead
59 | * removed the `getEnhanceWindowsCompatibility()` and `setEnhanceWindowsCompatibility()` methods of the `Process` class
60 | * passing a not existing working directory to the constructor of the `Symfony\Component\Process\Process` class is not
61 | supported anymore
62 |
63 | 3.4.0
64 | -----
65 |
66 | * deprecated the ProcessBuilder class
67 | * deprecated calling `Process::start()` without setting a valid working directory beforehand (via `setWorkingDirectory()` or constructor)
68 |
69 | 3.3.0
70 | -----
71 |
72 | * added command line arrays in the `Process` class
73 | * added `$env` argument to `Process::start()`, `run()`, `mustRun()` and `restart()` methods
74 | * deprecated the `ProcessUtils::escapeArgument()` method
75 | * deprecated not inheriting environment variables
76 | * deprecated configuring `proc_open()` options
77 | * deprecated configuring enhanced Windows compatibility
78 | * deprecated configuring enhanced sigchild compatibility
79 |
80 | 2.5.0
81 | -----
82 |
83 | * added support for PTY mode
84 | * added the convenience method "mustRun"
85 | * deprecation: Process::setStdin() is deprecated in favor of Process::setInput()
86 | * deprecation: Process::getStdin() is deprecated in favor of Process::getInput()
87 | * deprecation: Process::setInput() and ProcessBuilder::setInput() do not accept non-scalar types
88 |
89 | 2.4.0
90 | -----
91 |
92 | * added the ability to define an idle timeout
93 |
94 | 2.3.0
95 | -----
96 |
97 | * added ProcessUtils::escapeArgument() to fix the bug in escapeshellarg() function on Windows
98 | * added Process::signal()
99 | * added Process::getPid()
100 | * added support for a TTY mode
101 |
102 | 2.2.0
103 | -----
104 |
105 | * added ProcessBuilder::setArguments() to reset the arguments on a builder
106 | * added a way to retrieve the standard and error output incrementally
107 | * added Process:restart()
108 |
109 | 2.1.0
110 | -----
111 |
112 | * added support for non-blocking processes (start(), wait(), isRunning(), stop())
113 | * enhanced Windows compatibility
114 | * added Process::getExitCodeText() that returns a string representation for
115 | the exit code returned by the process
116 | * added ProcessBuilder
117 |
--------------------------------------------------------------------------------
/vendor/symfony/process/Pipes/UnixPipes.php:
--------------------------------------------------------------------------------
1 |
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 | namespace Symfony\Component\Process\Pipes;
13 |
14 | use Symfony\Component\Process\Process;
15 |
16 | /**
17 | * UnixPipes implementation uses unix pipes as handles.
18 | *
19 | * @author Romain Neutron
20 | *
21 | * @internal
22 | */
23 | class UnixPipes extends AbstractPipes
24 | {
25 | private $ttyMode;
26 | private $ptyMode;
27 | private $haveReadSupport;
28 |
29 | public function __construct(?bool $ttyMode, bool $ptyMode, $input, bool $haveReadSupport)
30 | {
31 | $this->ttyMode = $ttyMode;
32 | $this->ptyMode = $ptyMode;
33 | $this->haveReadSupport = $haveReadSupport;
34 |
35 | parent::__construct($input);
36 | }
37 |
38 | public function __sleep(): array
39 | {
40 | throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
41 | }
42 |
43 | public function __wakeup()
44 | {
45 | throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
46 | }
47 |
48 | public function __destruct()
49 | {
50 | $this->close();
51 | }
52 |
53 | /**
54 | * {@inheritdoc}
55 | */
56 | public function getDescriptors(): array
57 | {
58 | if (!$this->haveReadSupport) {
59 | $nullstream = fopen('/dev/null', 'c');
60 |
61 | return [
62 | ['pipe', 'r'],
63 | $nullstream,
64 | $nullstream,
65 | ];
66 | }
67 |
68 | if ($this->ttyMode) {
69 | return [
70 | ['file', '/dev/tty', 'r'],
71 | ['file', '/dev/tty', 'w'],
72 | ['file', '/dev/tty', 'w'],
73 | ];
74 | }
75 |
76 | if ($this->ptyMode && Process::isPtySupported()) {
77 | return [
78 | ['pty'],
79 | ['pty'],
80 | ['pty'],
81 | ];
82 | }
83 |
84 | return [
85 | ['pipe', 'r'],
86 | ['pipe', 'w'], // stdout
87 | ['pipe', 'w'], // stderr
88 | ];
89 | }
90 |
91 | /**
92 | * {@inheritdoc}
93 | */
94 | public function getFiles(): array
95 | {
96 | return [];
97 | }
98 |
99 | /**
100 | * {@inheritdoc}
101 | */
102 | public function readAndWrite(bool $blocking, bool $close = false): array
103 | {
104 | $this->unblock();
105 | $w = $this->write();
106 |
107 | $read = $e = [];
108 | $r = $this->pipes;
109 | unset($r[0]);
110 |
111 | // let's have a look if something changed in streams
112 | set_error_handler([$this, 'handleError']);
113 | if (($r || $w) && false === stream_select($r, $w, $e, 0, $blocking ? Process::TIMEOUT_PRECISION * 1E6 : 0)) {
114 | restore_error_handler();
115 | // if a system call has been interrupted, forget about it, let's try again
116 | // otherwise, an error occurred, let's reset pipes
117 | if (!$this->hasSystemCallBeenInterrupted()) {
118 | $this->pipes = [];
119 | }
120 |
121 | return $read;
122 | }
123 | restore_error_handler();
124 |
125 | foreach ($r as $pipe) {
126 | // prior PHP 5.4 the array passed to stream_select is modified and
127 | // lose key association, we have to find back the key
128 | $read[$type = array_search($pipe, $this->pipes, true)] = '';
129 |
130 | do {
131 | $data = @fread($pipe, self::CHUNK_SIZE);
132 | $read[$type] .= $data;
133 | } while (isset($data[0]) && ($close || isset($data[self::CHUNK_SIZE - 1])));
134 |
135 | if (!isset($read[$type][0])) {
136 | unset($read[$type]);
137 | }
138 |
139 | if ($close && feof($pipe)) {
140 | fclose($pipe);
141 | unset($this->pipes[$type]);
142 | }
143 | }
144 |
145 | return $read;
146 | }
147 |
148 | /**
149 | * {@inheritdoc}
150 | */
151 | public function haveReadSupport(): bool
152 | {
153 | return $this->haveReadSupport;
154 | }
155 |
156 | /**
157 | * {@inheritdoc}
158 | */
159 | public function areOpen(): bool
160 | {
161 | return (bool) $this->pipes;
162 | }
163 | }
164 |
--------------------------------------------------------------------------------
/tests/Unit/Filter/AuditScoreClassifierTest.php:
--------------------------------------------------------------------------------
1 | assertSame([
42 | "100% is classified as FAST!
\n Values between 90% – 100% are in this classification group.",
43 | "90% is classified as FAST!
\n Values between 90% – 100% are in this classification group.",
44 | "89.999% is classified as MODERATE!
\n Values between 50% – 90% are in this classification group.",
45 | "50% is classified as MODERATE!
\n Values between 50% – 90% are in this classification group.",
46 | "49.999% is classified as SLOW!
\n Values between 0% – 50% are in this classification group.",
47 | "0% is classified as SLOW!
\n Values between 0% – 50% are in this classification group.",
48 | "-1% is out of range of all classification groups.",
49 | "200% is out of range of all classification groups.",
50 | "",
51 | ""
52 | ], $tooltips);
53 | }
54 |
55 | public function test_get_correct_first_contentful_paint_tooltips()
56 | {
57 | $tooltips = [
58 | AuditScoreClassifier::getTooltip('0', 'PerformanceAudit_Report_FirstContentfulPaint_Mobile'),
59 | AuditScoreClassifier::getTooltip('1.999', 'PerformanceAudit_Report_FirstContentfulPaint_Mobile'),
60 | AuditScoreClassifier::getTooltip('2', 'PerformanceAudit_Report_FirstContentfulPaint_Mobile'),
61 | AuditScoreClassifier::getTooltip('3.999', 'PerformanceAudit_Report_FirstContentfulPaint_Mobile'),
62 | AuditScoreClassifier::getTooltip('4', 'PerformanceAudit_Report_FirstContentfulPaint_Mobile'),
63 | AuditScoreClassifier::getTooltip('5', 'PerformanceAudit_Report_FirstContentfulPaint_Mobile'),
64 | AuditScoreClassifier::getTooltip('60', 'PerformanceAudit_Report_FirstContentfulPaint_Mobile'),
65 | AuditScoreClassifier::getTooltip('200', 'PerformanceAudit_Report_FirstContentfulPaint_Mobile'),
66 | AuditScoreClassifier::getTooltip('', 'PerformanceAudit_Report_FirstContentfulPaint_Mobile'),
67 | AuditScoreClassifier::getTooltip('test', 'PerformanceAudit_Report_FirstContentfulPaint_Mobile'),
68 | ];
69 |
70 | $this->assertSame([
71 | "0s is classified as FAST!
\n Values between 0s – 2s are in this classification group.",
72 | "1.999s is classified as FAST!
\n Values between 0s – 2s are in this classification group.",
73 | "2s is classified as MODERATE!
\n Values between 2s – 4s are in this classification group.",
74 | "3.999s is classified as MODERATE!
\n Values between 2s – 4s are in this classification group.",
75 | "4s is classified as SLOW!
\n Values between 4s – 60s are in this classification group.",
76 | "5s is classified as SLOW!
\n Values between 4s – 60s are in this classification group.",
77 | "60s is classified as SLOW!
\n Values between 4s – 60s are in this classification group.",
78 | "200s is out of range of all classification groups.",
79 | "",
80 | ""
81 | ], $tooltips);
82 | }
83 | }
84 |
--------------------------------------------------------------------------------