From 045db2fd56c79f68390579ecc00d8f80c2f3d21e Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Tue, 26 Mar 2024 19:25:47 +0000 Subject: [PATCH] Updated Rector to commit f254215a5ac2877d4fb99dbf7f7ab44c070f1333 https://github.com/rectorphp/rector-src/commit/f254215a5ac2877d4fb99dbf7f7ab44c070f1333 [Scope] Fix resolve Scope from fluent call (#5743) --- src/Application/VersionResolver.php | 4 +- src/Console/Command/CustomRuleCommand.php | 4 +- .../ExprScopeFromStmtNodeVisitor.php | 6 +- vendor/composer/installed.json | 18 +-- vendor/composer/installed.php | 2 +- vendor/composer/xdebug-handler/CHANGELOG.md | 7 +- vendor/composer/xdebug-handler/README.md | 15 +- vendor/composer/xdebug-handler/composer.json | 8 +- .../composer/xdebug-handler/src/Process.php | 1 + vendor/composer/xdebug-handler/src/Status.php | 32 ++++- .../xdebug-handler/src/XdebugHandler.php | 132 ++++++++++++------ 11 files changed, 153 insertions(+), 76 deletions(-) diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index 9790ff6141d..a1d1053689b 100644 --- a/src/Application/VersionResolver.php +++ b/src/Application/VersionResolver.php @@ -19,12 +19,12 @@ final class VersionResolver * @api * @var string */ - public const PACKAGE_VERSION = '83046fcc340c19fc65bc09db25bbc018b01d6f30'; + public const PACKAGE_VERSION = 'f254215a5ac2877d4fb99dbf7f7ab44c070f1333'; /** * @api * @var string */ - public const RELEASE_DATE = '2024-03-26 10:26:04'; + public const RELEASE_DATE = '2024-03-27 02:23:32'; /** * @var int */ diff --git a/src/Console/Command/CustomRuleCommand.php b/src/Console/Command/CustomRuleCommand.php index 7e570be22ae..7b0d9ee69c1 100644 --- a/src/Console/Command/CustomRuleCommand.php +++ b/src/Console/Command/CustomRuleCommand.php @@ -123,7 +123,7 @@ final class CustomRuleCommand extends Command $this->symfonyStyle->warning('No element found in ' . $phpunitFilePath . '. Rector could not add the rector test suite to it'); return; } - $phpunitXML = $this->updatePHPUnitXMLFile($domDocument, $testsuitesElement, $phpunitFilePath); + $phpunitXML = $this->updatePHPUnitXMLFile($domDocument, $testsuitesElement); FileSystem::write($phpunitFilePath, $phpunitXML, null); $this->symfonyStyle->success('We also update ' . $phpunitFilePath . ", to add a rector test suite.\n You can run the rector tests by running: phpunit --testsuite rector"); } @@ -146,7 +146,7 @@ final class CustomRuleCommand extends Command } return \false; } - private function updatePHPUnitXMLFile(DOMDocument $domDocument, DOMElement $testsuitesElement, string $phpunitFilePath) : string + private function updatePHPUnitXMLFile(DOMDocument $domDocument, DOMElement $testsuitesElement) : string { $domElement = $domDocument->createElement('testsuite'); $domElement->setAttribute('name', 'rector'); diff --git a/src/PHPStan/NodeVisitor/ExprScopeFromStmtNodeVisitor.php b/src/PHPStan/NodeVisitor/ExprScopeFromStmtNodeVisitor.php index 3df42a87633..6996722a1f3 100644 --- a/src/PHPStan/NodeVisitor/ExprScopeFromStmtNodeVisitor.php +++ b/src/PHPStan/NodeVisitor/ExprScopeFromStmtNodeVisitor.php @@ -59,7 +59,7 @@ final class ExprScopeFromStmtNodeVisitor extends NodeVisitorAbstract if (!$node instanceof Expr) { return null; } - if ($node->getAttribute(AttributeKey::EXPRESSION_DEPTH) < 2 && $node->getAttribute(AttributeKey::IS_ARG_VALUE) !== \true) { + if ($this->shouldSkipExpr($node)) { return null; } $scope = $node->getAttribute(AttributeKey::SCOPE); @@ -75,4 +75,8 @@ final class ExprScopeFromStmtNodeVisitor extends NodeVisitorAbstract } return null; } + private function shouldSkipExpr(Expr $expr) : bool + { + return $expr->getAttribute(AttributeKey::EXPRESSION_DEPTH) < 2 && $expr->getAttribute(AttributeKey::IS_ARG_VALUE) !== \true && $expr->getAttribute(AttributeKey::IS_PARAM_VAR) === \true; + } } diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 6f461e641d3..1de3854d065 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -227,17 +227,17 @@ }, { "name": "composer\/xdebug-handler", - "version": "3.0.3", - "version_normalized": "3.0.3.0", + "version": "3.0.4", + "version_normalized": "3.0.4.0", "source": { "type": "git", "url": "https:\/\/github.com\/composer\/xdebug-handler.git", - "reference": "ced299686f41dce890debac69273b47ffe98a40c" + "reference": "4f988f8fdf580d53bdb2d1278fe93d1ed5462255" }, "dist": { "type": "zip", - "url": "https:\/\/api.github.com\/repos\/composer\/xdebug-handler\/zipball\/ced299686f41dce890debac69273b47ffe98a40c", - "reference": "ced299686f41dce890debac69273b47ffe98a40c", + "url": "https:\/\/api.github.com\/repos\/composer\/xdebug-handler\/zipball\/4f988f8fdf580d53bdb2d1278fe93d1ed5462255", + "reference": "4f988f8fdf580d53bdb2d1278fe93d1ed5462255", "shasum": "" }, "require": { @@ -248,9 +248,9 @@ "require-dev": { "phpstan\/phpstan": "^1.0", "phpstan\/phpstan-strict-rules": "^1.1", - "symfony\/phpunit-bridge": "^6.0" + "phpunit\/phpunit": "^8.5 || ^9.6 || ^10.5" }, - "time": "2022-02-25T21:32:43+00:00", + "time": "2024-03-26T18:29:49+00:00", "type": "library", "installation-source": "dist", "autoload": { @@ -274,9 +274,9 @@ "performance" ], "support": { - "irc": "irc:\/\/irc.freenode.org\/composer", + "irc": "ircs:\/\/irc.libera.chat:6697\/composer", "issues": "https:\/\/github.com\/composer\/xdebug-handler\/issues", - "source": "https:\/\/github.com\/composer\/xdebug-handler\/tree\/3.0.3" + "source": "https:\/\/github.com\/composer\/xdebug-handler\/tree\/3.0.4" }, "funding": [ { diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index 2d1d20dfc18..7b6b171f08f 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -2,4 +2,4 @@ namespace RectorPrefix202403; -return array('root' => array('name' => 'rector/rector-src', 'pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => null, 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), 'dev' => \false), 'versions' => array('clue/ndjson-react' => array('pretty_version' => 'v1.3.0', 'version' => '1.3.0.0', 'reference' => '392dc165fce93b5bb5c637b67e59619223c931b0', 'type' => 'library', 'install_path' => __DIR__ . '/../clue/ndjson-react', 'aliases' => array(), 'dev_requirement' => \false), 'composer/pcre' => array('pretty_version' => '3.1.3', 'version' => '3.1.3.0', 'reference' => '5b16e25a5355f1f3afdfc2f954a0a80aec4826a8', 'type' => 'library', 'install_path' => __DIR__ . '/./pcre', 'aliases' => array(), 'dev_requirement' => \false), 'composer/semver' => array('pretty_version' => '3.4.0', 'version' => '3.4.0.0', 'reference' => '35e8d0af4486141bc745f23a29cc2091eb624a32', 'type' => 'library', 'install_path' => __DIR__ . '/./semver', 'aliases' => array(), 'dev_requirement' => \false), 'composer/xdebug-handler' => array('pretty_version' => '3.0.3', 'version' => '3.0.3.0', 'reference' => 'ced299686f41dce890debac69273b47ffe98a40c', 'type' => 'library', 'install_path' => __DIR__ . '/./xdebug-handler', 'aliases' => array(), 'dev_requirement' => \false), 'doctrine/inflector' => array('pretty_version' => '2.0.10', 'version' => '2.0.10.0', 'reference' => '5817d0659c5b50c9b950feb9af7b9668e2c436bc', 'type' => 'library', 'install_path' => __DIR__ . '/../doctrine/inflector', 'aliases' => array(), 'dev_requirement' => \false), 'evenement/evenement' => array('pretty_version' => 'v3.0.2', 'version' => '3.0.2.0', 'reference' => '0a16b0d71ab13284339abb99d9d2bd813640efbc', 'type' => 'library', 'install_path' => __DIR__ . '/../evenement/evenement', 'aliases' => array(), 'dev_requirement' => \false), 'fidry/cpu-core-counter' => array('pretty_version' => '1.1.0', 'version' => '1.1.0.0', 'reference' => 'f92996c4d5c1a696a6a970e20f7c4216200fcc42', 'type' => 'library', 'install_path' => __DIR__ . '/../fidry/cpu-core-counter', 'aliases' => array(), 'dev_requirement' => \false), 'illuminate/container' => array('pretty_version' => 'v10.48.4', 'version' => '10.48.4.0', 'reference' => 'ddc26273085fad3c471b2602ad820e0097ff7939', 'type' => 'library', 'install_path' => __DIR__ . '/../illuminate/container', 'aliases' => array(), 'dev_requirement' => \false), 'illuminate/contracts' => array('pretty_version' => 'v10.48.4', 'version' => '10.48.4.0', 'reference' => '8d7152c4a1f5d9cf7da3e8b71f23e4556f6138ac', 'type' => 'library', 'install_path' => __DIR__ . '/../illuminate/contracts', 'aliases' => array(), 'dev_requirement' => \false), 'nette/utils' => array('pretty_version' => 'v4.0.4', 'version' => '4.0.4.0', 'reference' => 'd3ad0aa3b9f934602cb3e3902ebccf10be34d218', 'type' => 'library', 'install_path' => __DIR__ . '/../nette/utils', 'aliases' => array(), 'dev_requirement' => \false), 'nikic/php-parser' => array('pretty_version' => 'v4.19.1', 'version' => '4.19.1.0', 'reference' => '4e1b88d21c69391150ace211e9eaf05810858d0b', 'type' => 'library', 'install_path' => __DIR__ . '/../nikic/php-parser', 'aliases' => array(), 'dev_requirement' => \false), 'ondram/ci-detector' => array('pretty_version' => '4.2.0', 'version' => '4.2.0.0', 'reference' => '8b0223b5ed235fd377c75fdd1bfcad05c0f168b8', 'type' => 'library', 'install_path' => __DIR__ . '/../ondram/ci-detector', 'aliases' => array(), 'dev_requirement' => \false), 'phpstan/phpdoc-parser' => array('pretty_version' => '1.27.0', 'version' => '1.27.0.0', 'reference' => '86e4d5a4b036f8f0be1464522f4c6b584c452757', 'type' => 'library', 'install_path' => __DIR__ . '/../phpstan/phpdoc-parser', 'aliases' => array(), 'dev_requirement' => \false), 'phpstan/phpstan' => array('dev_requirement' => \false, 'replaced' => array(0 => '^1.10.57')), 'psr/container' => array('pretty_version' => '2.0.2', 'version' => '2.0.2.0', 'reference' => 'c71ecc56dfe541dbd90c5360474fbc405f8d5963', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/container', 'aliases' => array(), 'dev_requirement' => \false), 'psr/container-implementation' => array('dev_requirement' => \false, 'provided' => array(0 => '1.1|2.0')), 'psr/log' => array('pretty_version' => '3.0.0', 'version' => '3.0.0.0', 'reference' => 'fe5ea303b0887d5caefd3d431c3e61ad47037001', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/log', 'aliases' => array(), 'dev_requirement' => \false), 'psr/log-implementation' => array('dev_requirement' => \false, 'provided' => array(0 => '1.0|2.0|3.0')), 'psr/simple-cache' => array('pretty_version' => '3.0.0', 'version' => '3.0.0.0', 'reference' => '764e0b3939f5ca87cb904f570ef9be2d78a07865', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/simple-cache', 'aliases' => array(), 'dev_requirement' => \false), 'react/cache' => array('pretty_version' => 'v1.2.0', 'version' => '1.2.0.0', 'reference' => 'd47c472b64aa5608225f47965a484b75c7817d5b', 'type' => 'library', 'install_path' => __DIR__ . '/../react/cache', 'aliases' => array(), 'dev_requirement' => \false), 'react/child-process' => array('pretty_version' => 'v0.6.5', 'version' => '0.6.5.0', 'reference' => 'e71eb1aa55f057c7a4a0d08d06b0b0a484bead43', 'type' => 'library', 'install_path' => __DIR__ . '/../react/child-process', 'aliases' => array(), 'dev_requirement' => \false), 'react/dns' => array('pretty_version' => 'v1.12.0', 'version' => '1.12.0.0', 'reference' => 'c134600642fa615b46b41237ef243daa65bb64ec', 'type' => 'library', 'install_path' => __DIR__ . '/../react/dns', 'aliases' => array(), 'dev_requirement' => \false), 'react/event-loop' => array('pretty_version' => 'v1.5.0', 'version' => '1.5.0.0', 'reference' => 'bbe0bd8c51ffc05ee43f1729087ed3bdf7d53354', 'type' => 'library', 'install_path' => __DIR__ . '/../react/event-loop', 'aliases' => array(), 'dev_requirement' => \false), 'react/promise' => array('pretty_version' => 'v2.11.0', 'version' => '2.11.0.0', 'reference' => '1a8460931ea36dc5c76838fec5734d55c88c6831', 'type' => 'library', 'install_path' => __DIR__ . '/../react/promise', 'aliases' => array(), 'dev_requirement' => \false), 'react/socket' => array('pretty_version' => 'v1.15.0', 'version' => '1.15.0.0', 'reference' => '216d3aec0b87f04a40ca04f481e6af01bdd1d038', 'type' => 'library', 'install_path' => __DIR__ . '/../react/socket', 'aliases' => array(), 'dev_requirement' => \false), 'react/stream' => array('pretty_version' => 'v1.3.0', 'version' => '1.3.0.0', 'reference' => '6fbc9672905c7d5a885f2da2fc696f65840f4a66', 'type' => 'library', 'install_path' => __DIR__ . '/../react/stream', 'aliases' => array(), 'dev_requirement' => \false), 'rector/extension-installer' => array('pretty_version' => '0.11.2', 'version' => '0.11.2.0', 'reference' => '05544e9b195863b8571ae2a3b903cbec7fa062e0', 'type' => 'composer-plugin', 'install_path' => __DIR__ . '/../rector/extension-installer', 'aliases' => array(), 'dev_requirement' => \false), 'rector/rector' => array('dev_requirement' => \false, 'replaced' => array(0 => 'dev-main')), 'rector/rector-doctrine' => array('pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => 'b3da143634de79b24a266afc07401cfe75a2c49c', 'type' => 'rector-extension', 'install_path' => __DIR__ . '/../rector/rector-doctrine', 'aliases' => array(0 => '9999999-dev'), 'dev_requirement' => \false), 'rector/rector-downgrade-php' => array('pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => 'eadea252dae87d8703ce171ec8fb2682f455c5b9', 'type' => 'rector-extension', 'install_path' => __DIR__ . '/../rector/rector-downgrade-php', 'aliases' => array(0 => '9999999-dev'), 'dev_requirement' => \false), 'rector/rector-phpunit' => array('pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => '6845db43ccd69ef990d399ff845a53ad66fa8085', 'type' => 'rector-extension', 'install_path' => __DIR__ . '/../rector/rector-phpunit', 'aliases' => array(0 => '0.11.x-dev'), 'dev_requirement' => \false), 'rector/rector-src' => array('pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => null, 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), 'dev_requirement' => \false), 'rector/rector-symfony' => array('pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => 'c8b64135bdaaec629f2abd81387485cf3a627a3f', 'type' => 'rector-extension', 'install_path' => __DIR__ . '/../rector/rector-symfony', 'aliases' => array(0 => '9999999-dev'), 'dev_requirement' => \false), 'sebastian/diff' => array('pretty_version' => '5.1.1', 'version' => '5.1.1.0', 'reference' => 'c41e007b4b62af48218231d6c2275e4c9b975b2e', 'type' => 'library', 'install_path' => __DIR__ . '/../sebastian/diff', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/console' => array('pretty_version' => 'v6.4.4', 'version' => '6.4.4.0', 'reference' => '0d9e4eb5ad413075624378f474c4167ea202de78', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/console', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/deprecation-contracts' => array('pretty_version' => 'v3.4.0', 'version' => '3.4.0.0', 'reference' => '7c3aff79d10325257a001fcf92d991f24fc967cf', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/deprecation-contracts', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/filesystem' => array('pretty_version' => 'v6.4.3', 'version' => '6.4.3.0', 'reference' => '7f3b1755eb49297a0827a7575d5d2b2fd11cc9fb', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/filesystem', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/finder' => array('pretty_version' => 'v6.4.0', 'version' => '6.4.0.0', 'reference' => '11d736e97f116ac375a81f96e662911a34cd50ce', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/finder', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/polyfill-ctype' => array('dev_requirement' => \false, 'replaced' => array(0 => '*')), 'symfony/polyfill-intl-grapheme' => array('dev_requirement' => \false, 'replaced' => array(0 => '*')), 'symfony/polyfill-mbstring' => array('pretty_version' => 'v1.29.0', 'version' => '1.29.0.0', 'reference' => '9773676c8a1bb1f8d4340a62efe641cf76eda7ec', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/polyfill-mbstring', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/process' => array('pretty_version' => 'v6.4.4', 'version' => '6.4.4.0', 'reference' => '710e27879e9be3395de2b98da3f52a946039f297', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/process', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/service-contracts' => array('pretty_version' => 'v3.4.1', 'version' => '3.4.1.0', 'reference' => 'fe07cbc8d837f60caf7018068e350cc5163681a0', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/service-contracts', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/string' => array('dev_requirement' => \false, 'replaced' => array(0 => '*')), 'symfony/yaml' => array('pretty_version' => 'v6.4.3', 'version' => '6.4.3.0', 'reference' => 'd75715985f0f94f978e3a8fa42533e10db921b90', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/yaml', 'aliases' => array(), 'dev_requirement' => \false), 'symplify/easy-parallel' => array('pretty_version' => '11.2.2', 'version' => '11.2.2.0', 'reference' => '8586c18bb8efb31cd192a4e5cc94ae7813f72ed9', 'type' => 'library', 'install_path' => __DIR__ . '/../symplify/easy-parallel', 'aliases' => array(), 'dev_requirement' => \false), 'symplify/rule-doc-generator-contracts' => array('pretty_version' => '11.2.0', 'version' => '11.2.0.0', 'reference' => '479cfcfd46047f80624aba931d9789e50475b5c6', 'type' => 'library', 'install_path' => __DIR__ . '/../symplify/rule-doc-generator-contracts', 'aliases' => array(), 'dev_requirement' => \false), 'webmozart/assert' => array('pretty_version' => '1.11.0', 'version' => '1.11.0.0', 'reference' => '11cb2199493b2f8a3b53e7f19068fc6aac760991', 'type' => 'library', 'install_path' => __DIR__ . '/../webmozart/assert', 'aliases' => array(), 'dev_requirement' => \false))); +return array('root' => array('name' => 'rector/rector-src', 'pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => null, 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), 'dev' => \false), 'versions' => array('clue/ndjson-react' => array('pretty_version' => 'v1.3.0', 'version' => '1.3.0.0', 'reference' => '392dc165fce93b5bb5c637b67e59619223c931b0', 'type' => 'library', 'install_path' => __DIR__ . '/../clue/ndjson-react', 'aliases' => array(), 'dev_requirement' => \false), 'composer/pcre' => array('pretty_version' => '3.1.3', 'version' => '3.1.3.0', 'reference' => '5b16e25a5355f1f3afdfc2f954a0a80aec4826a8', 'type' => 'library', 'install_path' => __DIR__ . '/./pcre', 'aliases' => array(), 'dev_requirement' => \false), 'composer/semver' => array('pretty_version' => '3.4.0', 'version' => '3.4.0.0', 'reference' => '35e8d0af4486141bc745f23a29cc2091eb624a32', 'type' => 'library', 'install_path' => __DIR__ . '/./semver', 'aliases' => array(), 'dev_requirement' => \false), 'composer/xdebug-handler' => array('pretty_version' => '3.0.4', 'version' => '3.0.4.0', 'reference' => '4f988f8fdf580d53bdb2d1278fe93d1ed5462255', 'type' => 'library', 'install_path' => __DIR__ . '/./xdebug-handler', 'aliases' => array(), 'dev_requirement' => \false), 'doctrine/inflector' => array('pretty_version' => '2.0.10', 'version' => '2.0.10.0', 'reference' => '5817d0659c5b50c9b950feb9af7b9668e2c436bc', 'type' => 'library', 'install_path' => __DIR__ . '/../doctrine/inflector', 'aliases' => array(), 'dev_requirement' => \false), 'evenement/evenement' => array('pretty_version' => 'v3.0.2', 'version' => '3.0.2.0', 'reference' => '0a16b0d71ab13284339abb99d9d2bd813640efbc', 'type' => 'library', 'install_path' => __DIR__ . '/../evenement/evenement', 'aliases' => array(), 'dev_requirement' => \false), 'fidry/cpu-core-counter' => array('pretty_version' => '1.1.0', 'version' => '1.1.0.0', 'reference' => 'f92996c4d5c1a696a6a970e20f7c4216200fcc42', 'type' => 'library', 'install_path' => __DIR__ . '/../fidry/cpu-core-counter', 'aliases' => array(), 'dev_requirement' => \false), 'illuminate/container' => array('pretty_version' => 'v10.48.4', 'version' => '10.48.4.0', 'reference' => 'ddc26273085fad3c471b2602ad820e0097ff7939', 'type' => 'library', 'install_path' => __DIR__ . '/../illuminate/container', 'aliases' => array(), 'dev_requirement' => \false), 'illuminate/contracts' => array('pretty_version' => 'v10.48.4', 'version' => '10.48.4.0', 'reference' => '8d7152c4a1f5d9cf7da3e8b71f23e4556f6138ac', 'type' => 'library', 'install_path' => __DIR__ . '/../illuminate/contracts', 'aliases' => array(), 'dev_requirement' => \false), 'nette/utils' => array('pretty_version' => 'v4.0.4', 'version' => '4.0.4.0', 'reference' => 'd3ad0aa3b9f934602cb3e3902ebccf10be34d218', 'type' => 'library', 'install_path' => __DIR__ . '/../nette/utils', 'aliases' => array(), 'dev_requirement' => \false), 'nikic/php-parser' => array('pretty_version' => 'v4.19.1', 'version' => '4.19.1.0', 'reference' => '4e1b88d21c69391150ace211e9eaf05810858d0b', 'type' => 'library', 'install_path' => __DIR__ . '/../nikic/php-parser', 'aliases' => array(), 'dev_requirement' => \false), 'ondram/ci-detector' => array('pretty_version' => '4.2.0', 'version' => '4.2.0.0', 'reference' => '8b0223b5ed235fd377c75fdd1bfcad05c0f168b8', 'type' => 'library', 'install_path' => __DIR__ . '/../ondram/ci-detector', 'aliases' => array(), 'dev_requirement' => \false), 'phpstan/phpdoc-parser' => array('pretty_version' => '1.27.0', 'version' => '1.27.0.0', 'reference' => '86e4d5a4b036f8f0be1464522f4c6b584c452757', 'type' => 'library', 'install_path' => __DIR__ . '/../phpstan/phpdoc-parser', 'aliases' => array(), 'dev_requirement' => \false), 'phpstan/phpstan' => array('dev_requirement' => \false, 'replaced' => array(0 => '^1.10.57')), 'psr/container' => array('pretty_version' => '2.0.2', 'version' => '2.0.2.0', 'reference' => 'c71ecc56dfe541dbd90c5360474fbc405f8d5963', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/container', 'aliases' => array(), 'dev_requirement' => \false), 'psr/container-implementation' => array('dev_requirement' => \false, 'provided' => array(0 => '1.1|2.0')), 'psr/log' => array('pretty_version' => '3.0.0', 'version' => '3.0.0.0', 'reference' => 'fe5ea303b0887d5caefd3d431c3e61ad47037001', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/log', 'aliases' => array(), 'dev_requirement' => \false), 'psr/log-implementation' => array('dev_requirement' => \false, 'provided' => array(0 => '1.0|2.0|3.0')), 'psr/simple-cache' => array('pretty_version' => '3.0.0', 'version' => '3.0.0.0', 'reference' => '764e0b3939f5ca87cb904f570ef9be2d78a07865', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/simple-cache', 'aliases' => array(), 'dev_requirement' => \false), 'react/cache' => array('pretty_version' => 'v1.2.0', 'version' => '1.2.0.0', 'reference' => 'd47c472b64aa5608225f47965a484b75c7817d5b', 'type' => 'library', 'install_path' => __DIR__ . '/../react/cache', 'aliases' => array(), 'dev_requirement' => \false), 'react/child-process' => array('pretty_version' => 'v0.6.5', 'version' => '0.6.5.0', 'reference' => 'e71eb1aa55f057c7a4a0d08d06b0b0a484bead43', 'type' => 'library', 'install_path' => __DIR__ . '/../react/child-process', 'aliases' => array(), 'dev_requirement' => \false), 'react/dns' => array('pretty_version' => 'v1.12.0', 'version' => '1.12.0.0', 'reference' => 'c134600642fa615b46b41237ef243daa65bb64ec', 'type' => 'library', 'install_path' => __DIR__ . '/../react/dns', 'aliases' => array(), 'dev_requirement' => \false), 'react/event-loop' => array('pretty_version' => 'v1.5.0', 'version' => '1.5.0.0', 'reference' => 'bbe0bd8c51ffc05ee43f1729087ed3bdf7d53354', 'type' => 'library', 'install_path' => __DIR__ . '/../react/event-loop', 'aliases' => array(), 'dev_requirement' => \false), 'react/promise' => array('pretty_version' => 'v2.11.0', 'version' => '2.11.0.0', 'reference' => '1a8460931ea36dc5c76838fec5734d55c88c6831', 'type' => 'library', 'install_path' => __DIR__ . '/../react/promise', 'aliases' => array(), 'dev_requirement' => \false), 'react/socket' => array('pretty_version' => 'v1.15.0', 'version' => '1.15.0.0', 'reference' => '216d3aec0b87f04a40ca04f481e6af01bdd1d038', 'type' => 'library', 'install_path' => __DIR__ . '/../react/socket', 'aliases' => array(), 'dev_requirement' => \false), 'react/stream' => array('pretty_version' => 'v1.3.0', 'version' => '1.3.0.0', 'reference' => '6fbc9672905c7d5a885f2da2fc696f65840f4a66', 'type' => 'library', 'install_path' => __DIR__ . '/../react/stream', 'aliases' => array(), 'dev_requirement' => \false), 'rector/extension-installer' => array('pretty_version' => '0.11.2', 'version' => '0.11.2.0', 'reference' => '05544e9b195863b8571ae2a3b903cbec7fa062e0', 'type' => 'composer-plugin', 'install_path' => __DIR__ . '/../rector/extension-installer', 'aliases' => array(), 'dev_requirement' => \false), 'rector/rector' => array('dev_requirement' => \false, 'replaced' => array(0 => 'dev-main')), 'rector/rector-doctrine' => array('pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => 'b3da143634de79b24a266afc07401cfe75a2c49c', 'type' => 'rector-extension', 'install_path' => __DIR__ . '/../rector/rector-doctrine', 'aliases' => array(0 => '9999999-dev'), 'dev_requirement' => \false), 'rector/rector-downgrade-php' => array('pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => 'eadea252dae87d8703ce171ec8fb2682f455c5b9', 'type' => 'rector-extension', 'install_path' => __DIR__ . '/../rector/rector-downgrade-php', 'aliases' => array(0 => '9999999-dev'), 'dev_requirement' => \false), 'rector/rector-phpunit' => array('pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => '6845db43ccd69ef990d399ff845a53ad66fa8085', 'type' => 'rector-extension', 'install_path' => __DIR__ . '/../rector/rector-phpunit', 'aliases' => array(0 => '0.11.x-dev'), 'dev_requirement' => \false), 'rector/rector-src' => array('pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => null, 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), 'dev_requirement' => \false), 'rector/rector-symfony' => array('pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => 'c8b64135bdaaec629f2abd81387485cf3a627a3f', 'type' => 'rector-extension', 'install_path' => __DIR__ . '/../rector/rector-symfony', 'aliases' => array(0 => '9999999-dev'), 'dev_requirement' => \false), 'sebastian/diff' => array('pretty_version' => '5.1.1', 'version' => '5.1.1.0', 'reference' => 'c41e007b4b62af48218231d6c2275e4c9b975b2e', 'type' => 'library', 'install_path' => __DIR__ . '/../sebastian/diff', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/console' => array('pretty_version' => 'v6.4.4', 'version' => '6.4.4.0', 'reference' => '0d9e4eb5ad413075624378f474c4167ea202de78', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/console', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/deprecation-contracts' => array('pretty_version' => 'v3.4.0', 'version' => '3.4.0.0', 'reference' => '7c3aff79d10325257a001fcf92d991f24fc967cf', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/deprecation-contracts', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/filesystem' => array('pretty_version' => 'v6.4.3', 'version' => '6.4.3.0', 'reference' => '7f3b1755eb49297a0827a7575d5d2b2fd11cc9fb', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/filesystem', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/finder' => array('pretty_version' => 'v6.4.0', 'version' => '6.4.0.0', 'reference' => '11d736e97f116ac375a81f96e662911a34cd50ce', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/finder', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/polyfill-ctype' => array('dev_requirement' => \false, 'replaced' => array(0 => '*')), 'symfony/polyfill-intl-grapheme' => array('dev_requirement' => \false, 'replaced' => array(0 => '*')), 'symfony/polyfill-mbstring' => array('pretty_version' => 'v1.29.0', 'version' => '1.29.0.0', 'reference' => '9773676c8a1bb1f8d4340a62efe641cf76eda7ec', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/polyfill-mbstring', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/process' => array('pretty_version' => 'v6.4.4', 'version' => '6.4.4.0', 'reference' => '710e27879e9be3395de2b98da3f52a946039f297', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/process', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/service-contracts' => array('pretty_version' => 'v3.4.1', 'version' => '3.4.1.0', 'reference' => 'fe07cbc8d837f60caf7018068e350cc5163681a0', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/service-contracts', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/string' => array('dev_requirement' => \false, 'replaced' => array(0 => '*')), 'symfony/yaml' => array('pretty_version' => 'v6.4.3', 'version' => '6.4.3.0', 'reference' => 'd75715985f0f94f978e3a8fa42533e10db921b90', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/yaml', 'aliases' => array(), 'dev_requirement' => \false), 'symplify/easy-parallel' => array('pretty_version' => '11.2.2', 'version' => '11.2.2.0', 'reference' => '8586c18bb8efb31cd192a4e5cc94ae7813f72ed9', 'type' => 'library', 'install_path' => __DIR__ . '/../symplify/easy-parallel', 'aliases' => array(), 'dev_requirement' => \false), 'symplify/rule-doc-generator-contracts' => array('pretty_version' => '11.2.0', 'version' => '11.2.0.0', 'reference' => '479cfcfd46047f80624aba931d9789e50475b5c6', 'type' => 'library', 'install_path' => __DIR__ . '/../symplify/rule-doc-generator-contracts', 'aliases' => array(), 'dev_requirement' => \false), 'webmozart/assert' => array('pretty_version' => '1.11.0', 'version' => '1.11.0.0', 'reference' => '11cb2199493b2f8a3b53e7f19068fc6aac760991', 'type' => 'library', 'install_path' => __DIR__ . '/../webmozart/assert', 'aliases' => array(), 'dev_requirement' => \false))); diff --git a/vendor/composer/xdebug-handler/CHANGELOG.md b/vendor/composer/xdebug-handler/CHANGELOG.md index c5b5bcf4e1a..49fdc45d45a 100644 --- a/vendor/composer/xdebug-handler/CHANGELOG.md +++ b/vendor/composer/xdebug-handler/CHANGELOG.md @@ -1,5 +1,9 @@ ## [Unreleased] +## [3.0.4] - 2024-03-26 + * Added: Functional tests. + * Fixed: Incompatibility with PHPUnit 10. + ## [3.0.3] - 2022-02-25 * Added: support for composer/pcre versions 2 and 3. @@ -108,7 +112,8 @@ * Break: the following class was renamed: - `Composer\XdebugHandler` -> `Composer\XdebugHandler\XdebugHandler` -[Unreleased]: https://github.com/composer/xdebug-handler/compare/3.0.3...HEAD +[Unreleased]: https://github.com/composer/xdebug-handler/compare/3.0.4...HEAD +[3.0.3]: https://github.com/composer/xdebug-handler/compare/3.0.3...3.0.4 [3.0.2]: https://github.com/composer/xdebug-handler/compare/3.0.2...3.0.3 [3.0.2]: https://github.com/composer/xdebug-handler/compare/3.0.1...3.0.2 [3.0.1]: https://github.com/composer/xdebug-handler/compare/3.0.0...3.0.1 diff --git a/vendor/composer/xdebug-handler/README.md b/vendor/composer/xdebug-handler/README.md index 56618fc14a8..f7f581ac251 100644 --- a/vendor/composer/xdebug-handler/README.md +++ b/vendor/composer/xdebug-handler/README.md @@ -51,6 +51,7 @@ The constructor takes a single parameter, `$envPrefix`, which is upper-cased and * [Process configuration](#process-configuration) * [Troubleshooting](#troubleshooting) * [Extending the library](#extending-the-library) +* [Examples](#examples) ### How it works @@ -64,6 +65,8 @@ A temporary ini file is created from the loaded (and scanned) ini files, with an * The application runs and exits. * The main process exits with the exit code from the restarted process. +See [Examples](#examples) for further information. + #### Signal handling Asynchronous signal handling is automatically enabled if the pcntl extension is loaded. `SIGINT` is set to `SIG_IGN` in the parent process and restored to `SIG_DFL` in the restarted process (if no other handler has been set). @@ -74,7 +77,7 @@ From PHP 7.4 on Windows, `CTRL+C` and `CTRL+BREAK` handling is automatically ena There are a few things to be aware of when running inside a restarted process. * Extensions set on the command-line will not be loaded. -* Ini file locations will be reported as per the restart - see [getAllIniFiles()](#getallinifiles). +* Ini file locations will be reported as per the restart - see [getAllIniFiles()](#getallinifiles-array). * Php sub-processes may be loaded with Xdebug enabled - see [Process configuration](#process-configuration). ### Helper methods @@ -200,12 +203,12 @@ Uses environment variables to remove Xdebug from the new process and persist the >_If the new process calls a PHP sub-process, Xdebug will not be loaded in that sub-process._ -This strategy can be used in the restart by calling [setPersistent()](#setpersistent). +This strategy can be used in the restart by calling [setPersistent()](#setpersistent-self). #### Sub-processes The `PhpConfig` helper class makes it easy to invoke a PHP sub-process (with or without Xdebug loaded), regardless of whether there has been a restart. -Each of its methods returns an array of PHP options (to add to the command-line) and sets up the environment for the required strategy. The [getRestartSettings()](#getrestartsettings) method is used internally. +Each of its methods returns an array of PHP options (to add to the command-line) and sets up the environment for the required strategy. The [getRestartSettings()](#getrestartsettings-array) method is used internally. * `useOriginal()` - Xdebug will be loaded in the new process. * `useStandard()` - Xdebug will **not** be loaded in the new process - see [standard settings](#standard-settings). @@ -245,7 +248,7 @@ The API is defined by classes and their accessible elements that are not annotat By default the process will restart if Xdebug is loaded and not running with `xdebug.mode=off`. Extending this method allows an application to decide, by returning a boolean (or equivalent) value. It is only called if `MYAPP_ALLOW_XDEBUG` is empty, so it will not be called in the restarted process (where this variable contains internal data), or if the restart has been overridden. -Note that the [setMainScript()](#setmainscriptscript) and [setPersistent()](#setpersistent) setters can be used here, if required. +Note that the [setMainScript()](#setmainscriptstring-script-self) and [setPersistent()](#setpersistent-self) setters can be used here, if required. #### _restart(array $command): void_ An application can extend this to modify the temporary ini file, its location given in the `tmpIni` property. New settings can be safely appended to the end of the data, which is `PHP_EOL` terminated. @@ -294,5 +297,9 @@ class MyRestarter extends XdebugHandler } ``` +### Examples +The `tests\App` directory contains command-line scripts that demonstrate the internal workings in a variety of scenarios. +See [Functional Test Scripts](./tests/App/README.md). + ## License composer/xdebug-handler is licensed under the MIT License, see the LICENSE file for details. diff --git a/vendor/composer/xdebug-handler/composer.json b/vendor/composer/xdebug-handler/composer.json index 222236788e4..eee4b7ecfd8 100644 --- a/vendor/composer/xdebug-handler/composer.json +++ b/vendor/composer/xdebug-handler/composer.json @@ -14,7 +14,7 @@ } ], "support": { - "irc": "irc:\/\/irc.freenode.org\/composer", + "irc": "ircs:\/\/irc.libera.chat:6697\/composer", "issues": "https:\/\/github.com\/composer\/xdebug-handler\/issues" }, "require": { @@ -23,9 +23,9 @@ "composer\/pcre": "^1 || ^2 || ^3" }, "require-dev": { - "symfony\/phpunit-bridge": "^6.0", "phpstan\/phpstan": "^1.0", - "phpstan\/phpstan-strict-rules": "^1.1" + "phpstan\/phpstan-strict-rules": "^1.1", + "phpunit\/phpunit": "^8.5 || ^9.6 || ^10.5" }, "autoload": { "psr-4": { @@ -38,7 +38,7 @@ } }, "scripts": { - "test": "@php vendor\/bin\/simple-phpunit", + "test": "@php vendor\/bin\/phpunit", "phpstan": "@php vendor\/bin\/phpstan analyse" } } \ No newline at end of file diff --git a/vendor/composer/xdebug-handler/src/Process.php b/vendor/composer/xdebug-handler/src/Process.php index 5a663fd9b3b..bd70f25a2a6 100644 --- a/vendor/composer/xdebug-handler/src/Process.php +++ b/vendor/composer/xdebug-handler/src/Process.php @@ -36,6 +36,7 @@ class Process } $quote = \strpbrk($arg, " \t") !== \false || $arg === ''; $arg = Preg::replace('/(\\\\*)"/', '$1$1\\"', $arg, -1, $dquotes); + $dquotes = (bool) $dquotes; if ($meta) { $meta = $dquotes || Preg::isMatch('/%[^%]+%/', $arg); if (!$meta) { diff --git a/vendor/composer/xdebug-handler/src/Status.php b/vendor/composer/xdebug-handler/src/Status.php index 9ba9c3e40f9..4891189ed68 100644 --- a/vendor/composer/xdebug-handler/src/Status.php +++ b/vendor/composer/xdebug-handler/src/Status.php @@ -69,12 +69,32 @@ class Status public function report(string $op, ?string $data) : void { if ($this->logger !== null || $this->debug) { - $callable = [$this, 'report' . $op]; - if (!\is_callable($callable)) { - throw new \InvalidArgumentException('Unknown op handler: ' . $op); + $param = (string) $data; + switch ($op) { + case self::CHECK: + $this->reportCheck($param); + break; + case self::ERROR: + $this->reportError($param); + break; + case self::INFO: + $this->reportInfo($param); + break; + case self::NORESTART: + $this->reportNoRestart(); + break; + case self::RESTART: + $this->reportRestart(); + break; + case self::RESTARTED: + $this->reportRestarted(); + break; + case self::RESTARTING: + $this->reportRestarting($param); + break; + default: + throw new \InvalidArgumentException('Unknown op handler: ' . $op); } - $params = $data !== null ? [$data] : []; - \call_user_func_array($callable, $params); } } /** @@ -154,7 +174,7 @@ class Status { $text = \sprintf('Process restarting (%s)', $this->getEnvAllow()); $this->output($text); - $text = 'Running ' . $command; + $text = 'Running: ' . $command; $this->output($text); } /** diff --git a/vendor/composer/xdebug-handler/src/XdebugHandler.php b/vendor/composer/xdebug-handler/src/XdebugHandler.php index 599113d20ed..d13f44bf47e 100644 --- a/vendor/composer/xdebug-handler/src/XdebugHandler.php +++ b/vendor/composer/xdebug-handler/src/XdebugHandler.php @@ -116,8 +116,8 @@ class XdebugHandler if (!(bool) $envArgs[0] && $this->requiresRestart(self::$xdebugActive)) { // Restart required $this->notify(Status::RESTART); - if ($this->prepareRestart()) { - $command = $this->getCommand(); + $command = $this->prepareRestart(); + if ($command !== null) { $this->restart($command); } return; @@ -147,9 +147,9 @@ class XdebugHandler * Returns an array of php.ini locations with at least one entry * * The equivalent of calling php_ini_loaded_file then php_ini_scanned_files. - * The loaded ini location is the first entry and may be empty. + * The loaded ini location is the first entry and may be an empty string. * - * @return string[] + * @return non-empty-list */ public static function getAllIniFiles() : array { @@ -212,7 +212,7 @@ class XdebugHandler /** * Allows an extending class to access the tmpIni * - * @param string[] $command * + * @param non-empty-list $command */ protected function restart(array $command) : void { @@ -221,22 +221,24 @@ class XdebugHandler /** * Executes the restarted command then deletes the tmp ini * - * @param string[] $command + * @param non-empty-list $command * @phpstan-return never */ private function doRestart(array $command) : void { - $this->tryEnableSignals(); - $this->notify(Status::RESTARTING, \implode(' ', $command)); if (\PHP_VERSION_ID >= 70400) { $cmd = $command; + $displayCmd = \sprintf('[%s]', \implode(', ', $cmd)); } else { $cmd = Process::escapeShellCommand($command); if (\defined('PHP_WINDOWS_VERSION_BUILD')) { // Outer quotes required on cmd string below PHP 8 $cmd = '"' . $cmd . '"'; } + $displayCmd = $cmd; } + $this->tryEnableSignals(); + $this->notify(Status::RESTARTING, $displayCmd); $process = \proc_open(\is_array($cmd) ? \implode(' ', \array_map('escapeshellarg', $cmd)) : $cmd, [], $pipes); if (\is_resource($process)) { $exitCode = \proc_close($process); @@ -256,46 +258,63 @@ class XdebugHandler exit($exitCode); } /** - * Returns true if everything was written for the restart + * Returns the command line array if everything was written for the restart * * If any of the following fails (however unlikely) we must return false to * stop potential recursion: * - tmp ini file creation * - environment variable creation + * + * @return non-empty-list|null */ - private function prepareRestart() : bool + private function prepareRestart() : ?array { + if (!$this->cli) { + $this->notify(Status::ERROR, 'Unsupported SAPI: ' . \PHP_SAPI); + return null; + } + if (($argv = $this->checkServerArgv()) === null) { + $this->notify(Status::ERROR, '$_SERVER[argv] is not as expected'); + return null; + } + if (!$this->checkConfiguration($info)) { + $this->notify(Status::ERROR, $info); + return null; + } + $mainScript = (string) $this->script; + if (!$this->checkMainScript($mainScript, $argv)) { + $this->notify(Status::ERROR, 'Unable to access main script: ' . $mainScript); + return null; + } + $tmpDir = \sys_get_temp_dir(); + $iniError = 'Unable to create temp ini file at: ' . $tmpDir; + if (($tmpfile = @\tempnam($tmpDir, '')) === \false) { + $this->notify(Status::ERROR, $iniError); + return null; + } $error = null; $iniFiles = self::getAllIniFiles(); $scannedInis = \count($iniFiles) > 1; - $tmpDir = \sys_get_temp_dir(); - if (!$this->cli) { - $error = 'Unsupported SAPI: ' . \PHP_SAPI; - } elseif (!$this->checkConfiguration($info)) { - $error = $info; - } elseif (!$this->checkMainScript()) { - $error = 'Unable to access main script: ' . $this->script; - } elseif (!$this->writeTmpIni($iniFiles, $tmpDir, $error)) { - $error = $error !== null ? $error : 'Unable to create temp ini file at: ' . $tmpDir; - } elseif (!$this->setEnvironment($scannedInis, $iniFiles)) { - $error = 'Unable to set environment variables'; + if (!$this->writeTmpIni($tmpfile, $iniFiles, $error)) { + $this->notify(Status::ERROR, $error ?? $iniError); + @\unlink($tmpfile); + return null; } - if ($error !== null) { - $this->notify(Status::ERROR, $error); + if (!$this->setEnvironment($scannedInis, $iniFiles, $tmpfile)) { + $this->notify(Status::ERROR, 'Unable to set environment variables'); + @\unlink($tmpfile); + return null; } - return $error === null; + $this->tmpIni = $tmpfile; + return $this->getCommand($argv, $tmpfile, $mainScript); } /** * Returns true if the tmp ini file was written * - * @param string[] $iniFiles All ini files used in the current process + * @param non-empty-list $iniFiles All ini files used in the current process */ - private function writeTmpIni(array $iniFiles, string $tmpDir, ?string &$error) : bool + private function writeTmpIni(string $tmpFile, array $iniFiles, ?string &$error) : bool { - if (($tmpfile = @\tempnam($tmpDir, '')) === \false) { - return \false; - } - $this->tmpIni = $tmpfile; // $iniFiles has at least one item and it may be empty if ($iniFiles[0] === '') { \array_shift($iniFiles); @@ -310,7 +329,7 @@ class XdebugHandler return \false; } // Check and remove directives after HOST and PATH sections - if (Preg::isMatchWithOffsets($sectionRegex, $data, $matches, \PREG_OFFSET_CAPTURE)) { + if (Preg::isMatchWithOffsets($sectionRegex, $data, $matches)) { $data = \substr($data, 0, $matches[0][1]); } $content .= Preg::replace($xdebugRegex, ';$1', $data) . \PHP_EOL; @@ -325,31 +344,32 @@ class XdebugHandler $content .= $this->mergeLoadedConfig($loaded, $config); // Work-around for https://bugs.php.net/bug.php?id=75932 $content .= 'opcache.enable_cli=0' . \PHP_EOL; - return (bool) @\file_put_contents($this->tmpIni, $content); + return (bool) @\file_put_contents($tmpFile, $content); } /** * Returns the command line arguments for the restart * - * @return string[] + * @param non-empty-list $argv + * @return non-empty-list */ - private function getCommand() : array + private function getCommand(array $argv, string $tmpIni, string $mainScript) : array { $php = [\PHP_BINARY]; - $args = \array_slice($_SERVER['argv'], 1); + $args = \array_slice($argv, 1); if (!$this->persistent) { // Use command-line options - \array_push($php, '-n', '-c', $this->tmpIni); + \array_push($php, '-n', '-c', $tmpIni); } - return \array_merge($php, [$this->script], $args); + return \array_merge($php, [$mainScript], $args); } /** * Returns true if the restart environment variables were set * * No need to update $_SERVER since this is set in the restarted process. * - * @param string[] $iniFiles All ini files used in the current process + * @param non-empty-list $iniFiles All ini files used in the current process */ - private function setEnvironment(bool $scannedInis, array $iniFiles) : bool + private function setEnvironment(bool $scannedInis, array $iniFiles, string $tmpIni) : bool { $scanDir = \getenv('PHP_INI_SCAN_DIR'); $phprc = \getenv('PHPRC'); @@ -359,7 +379,7 @@ class XdebugHandler } if ($this->persistent) { // Use the environment to persist the settings - if (!\putenv('PHP_INI_SCAN_DIR=') || !\putenv('PHPRC=' . $this->tmpIni)) { + if (!\putenv('PHP_INI_SCAN_DIR=') || !\putenv('PHPRC=' . $tmpIni)) { return \false; } } @@ -398,28 +418,30 @@ class XdebugHandler } /** * Returns true if the script name can be used + * + * @param non-empty-list $argv */ - private function checkMainScript() : bool + private function checkMainScript(string &$mainScript, array $argv) : bool { - if ($this->script !== null) { + if ($mainScript !== '') { // Allow an application to set -- for standard input - return \file_exists($this->script) || '--' === $this->script; + return \file_exists($mainScript) || '--' === $mainScript; } - if (\file_exists($this->script = $_SERVER['argv'][0])) { + if (\file_exists($mainScript = $argv[0])) { return \true; } // Use a backtrace to resolve Phar and chdir issues. $trace = \debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS); $main = \end($trace); if ($main !== \false && isset($main['file'])) { - return \file_exists($this->script = $main['file']); + return \file_exists($mainScript = $main['file']); } return \false; } /** * Adds restart settings to the environment * - * @param string[] $envArgs + * @param non-empty-list $envArgs */ private function setEnvRestartSettings(array $envArgs) : void { @@ -498,6 +520,24 @@ class XdebugHandler }); } } + /** + * Returns $_SERVER['argv'] if it is as expected + * + * @return non-empty-list|null + */ + private function checkServerArgv() : ?array + { + $result = []; + if (isset($_SERVER['argv']) && \is_array($_SERVER['argv'])) { + foreach ($_SERVER['argv'] as $value) { + if (!\is_string($value)) { + return null; + } + $result[] = $value; + } + } + return \count($result) > 0 ? $result : null; + } /** * Sets static properties $xdebugActive, $xdebugVersion and $xdebugMode */