From fd2879a56946e40bac1f2fdb8fe9a0e22ae20ce9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20FIDRY?= Date: Sun, 12 Feb 2023 13:27:32 +0100 Subject: [PATCH 1/2] fix(requirement-checker): Fix enable/disabling the requirement checker If the `BOX_REQUIREMENT_CHECKER` environment variable is passed, it should only disable the requirement check if the value is `'0'` or `'false'` (case-insensitive). --- .github/workflows/requirement-checker.yaml | 2 ++ requirement-checker/Makefile | 2 +- requirement-checker/Makefile.e2e | 31 +++++++++++++++++++ .../bin/check-requirements.php | 24 +++++++++----- .../bin/check-requirements.php | 23 ++++++++++++-- .../vendor/composer/installed.php | 2 +- 6 files changed, 72 insertions(+), 12 deletions(-) diff --git a/.github/workflows/requirement-checker.yaml b/.github/workflows/requirement-checker.yaml index 22c332b21..9b684435a 100644 --- a/.github/workflows/requirement-checker.yaml +++ b/.github/workflows/requirement-checker.yaml @@ -193,6 +193,8 @@ jobs: docker-image: ghcr.io/box-project/box_php81 - command: _test_e2e_skip_min_composer_php docker-image: ghcr.io/box-project/box_php725 + - command: _test_e2e_pass_complete_requirement_checker_not_disabled + docker-image: ghcr.io/box-project/box_php725 steps: - name: Checkout uses: actions/checkout@v3 diff --git a/requirement-checker/Makefile b/requirement-checker/Makefile index 1312595ca..cb7528939 100644 --- a/requirement-checker/Makefile +++ b/requirement-checker/Makefile @@ -167,7 +167,7 @@ terminal_copy: $(ACTUAL_TERMINAL_DIFF) include Makefile.e2e .PHONY: test_e2e -test_e2e: docker_images _test_e2e_pass_no_config_min_composer_php _test_e2e_pass_no_config_min_box_php _test_e2e_pass_complete_min_composer_php _test_e2e_pass_complete_min_box_php _test_e2e_fail_complete_min_composer_php _test_e2e_fail_complete_min_box_php _test_e2e_skip_min_composer_php +test_e2e: docker_images _test_e2e_pass_no_config_min_composer_php _test_e2e_pass_no_config_min_box_php _test_e2e_pass_complete_min_composer_php _test_e2e_pass_complete_min_box_php _test_e2e_fail_complete_min_composer_php _test_e2e_fail_complete_min_box_php _test_e2e_skip_min_composer_php _test_e2e_pass_complete_requirement_checker_not_disabled # diff --git a/requirement-checker/Makefile.e2e b/requirement-checker/Makefile.e2e index fdd112255..ab1ef9fc2 100644 --- a/requirement-checker/Makefile.e2e +++ b/requirement-checker/Makefile.e2e @@ -175,6 +175,33 @@ _test_e2e_pass_complete_min_box_php: $(E2E_TEST_PASS_COMPLETE_PHAR) $(E2E_TEST_PASS_COMPLETE_ACTUAL_STDOUT) + +.PHONY: test_e2e_pass_complete_requirement_checker_not_disabled +test_e2e_pass_complete_requirement_checker_not_disabled: docker_images _test_e2e_pass_complete_requirement_checker_not_disabled + +.PHONY: _test_e2e_pass_complete_requirement_checker_not_disabled +_test_e2e_pass_complete_requirement_checker_not_disabled: $(E2E_TEST_PASS_COMPLETE_PHAR) + @echo "$(YELLOW_COLOR)Test RequirementChecker with a project with satisfied requirements (min PHP version supported by Box).$(NO_COLOR)" + @rm \ + $(E2E_TEST_PASS_COMPLETE_ACTUAL_STDOUT) \ + $(E2E_TEST_PASS_COMPLETE_ACTUAL_STDERR) \ + $(E2E_TEST_PASS_COMPLETE_MIN_BOX_EXPECTED_STDERR) || true + @$(MAKE) $(E2E_TEST_PASS_COMPLETE_MIN_BOX_EXPECTED_STDERR) + + $(DOCKER_RUN) \ + --env="BOX_REQUIREMENT_CHECKER=1" \ + --volume="$$PWD/$(E2E_TEST_PASS_COMPLETE_OUTPUT_DIR)":/opt/box \ + $(DOCKER_MIN_BOX_PHP_VERSION_RUN_COMMAND) 1>$(E2E_TEST_PASS_COMPLETE_ACTUAL_STDOUT) 2>$(E2E_TEST_PASS_COMPLETE_ACTUAL_STDERR) \ + || true + + $(DIFF) \ + $(E2E_TEST_PASS_COMPLETE_MIN_BOX_EXPECTED_STDERR) \ + $(E2E_TEST_PASS_COMPLETE_ACTUAL_STDERR) + $(DIFF) \ + $(E2E_TEST_PASS_COMPLETE_MIN_BOX_EXPECTED_STDOUT) \ + $(E2E_TEST_PASS_COMPLETE_ACTUAL_STDOUT) + + # # Fail Complete #--------------------------------------------------------------------------- @@ -324,3 +351,7 @@ $(E2E_TEST_SKIP_OUTPUT_DIR): $(E2E_TEST_SKIP_PHAR): $(E2E_TEST_SKIP_OUTPUT_DIR) $(E2E_TEST_FAIL_COMPLETE_PHAR) cp -f $(E2E_TEST_FAIL_COMPLETE_PHAR) $(E2E_TEST_SKIP_PHAR) touch -c $@ + + +$(SCOPED_BOX_BIN): + cd ..; make --file Makefile compile diff --git a/requirement-checker/bin/check-requirements.php b/requirement-checker/bin/check-requirements.php index 2463d7ebe..e6a34f008 100644 --- a/requirement-checker/bin/check-requirements.php +++ b/requirement-checker/bin/check-requirements.php @@ -12,12 +12,22 @@ namespace KevinGH\RequirementChecker; -if ( - isset($_SERVER['BOX_REQUIREMENT_CHECKER']) - || false === (bool) $_SERVER['BOX_REQUIREMENT_CHECKER'] -) { - // Do nothing. - return; +if (isset($_SERVER['BOX_REQUIREMENT_CHECKER'])) { + $enableRequirementChecker = $_SERVER['BOX_REQUIREMENT_CHECKER']; + + if (is_bool($enableRequirementChecker) && !$enableRequirementChecker) { + return; + } + + if (is_string($enableRequirementChecker) && in_array(strtolower($enableRequirementChecker), ['false', '0'], true)) { + return; + } + + if (!is_bool($enableRequirementChecker) && !is_string($enableRequirementChecker)) { + echo PHP_EOL.'Unhandled value type for "BOX_REQUIREMENT_CHECKER". Got "'.gettype($enableRequirementChecker).'". Proceeding with the requirement checks.'.PHP_EOL; + } + + // Continue } // Important: do this check _after_ the requirement checker flag. Indeed, if the requirement checker is disabled we do @@ -32,6 +42,6 @@ require __DIR__.'/../vendor/autoload.php'; -if (Checker::checkRequirements()) { +if (!Checker::checkRequirements()) { exit(1); } diff --git a/res/requirement-checker/bin/check-requirements.php b/res/requirement-checker/bin/check-requirements.php index e8a3284a3..2e7d7d6af 100644 --- a/res/requirement-checker/bin/check-requirements.php +++ b/res/requirement-checker/bin/check-requirements.php @@ -2,11 +2,28 @@ namespace HumbugBox420\KevinGH\RequirementChecker; -require __DIR__ . '/../vendor/autoload.php'; -if (\false === \in_array(\PHP_SAPI, array('cli', 'phpdbg', 'embed', 'micro'), \true)) { +use function gettype; +use function in_array; +use function is_bool; +use function is_string; +use function strtolower; +if (isset($_SERVER['BOX_REQUIREMENT_CHECKER'])) { + $enableRequirementChecker = $_SERVER['BOX_REQUIREMENT_CHECKER']; + if (is_bool($enableRequirementChecker) && !$enableRequirementChecker) { + return; + } + if (is_string($enableRequirementChecker) && in_array(strtolower($enableRequirementChecker), ['false', '0'], \true)) { + return; + } + if (!is_bool($enableRequirementChecker) && !is_string($enableRequirementChecker)) { + echo \PHP_EOL . 'Unhandled value type for "BOX_REQUIREMENT_CHECKER". Got "' . gettype($enableRequirementChecker) . '". Proceeding with the requirement checks.' . \PHP_EOL; + } +} +if (\false === in_array(\PHP_SAPI, array('cli', 'phpdbg', 'embed', 'micro'), \true)) { echo \PHP_EOL . 'The application may only be invoked from a command line, got "' . \PHP_SAPI . '"' . \PHP_EOL; exit(1); } -if ((\false === isset($_SERVER['BOX_REQUIREMENT_CHECKER']) || \true === (bool) $_SERVER['BOX_REQUIREMENT_CHECKER']) && \false === Checker::checkRequirements()) { +require __DIR__ . '/../vendor/autoload.php'; +if (!Checker::checkRequirements()) { exit(1); } diff --git a/res/requirement-checker/vendor/composer/installed.php b/res/requirement-checker/vendor/composer/installed.php index 33b423e11..1f4d0ffe7 100644 --- a/res/requirement-checker/vendor/composer/installed.php +++ b/res/requirement-checker/vendor/composer/installed.php @@ -2,4 +2,4 @@ namespace HumbugBox420; -return array('root' => array('name' => 'humbug/requirement-checker', 'pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => 'e787e608c1fb149aeb2b77e2fc76eeb2ab0f8be1', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), 'dev' => \true), 'versions' => array('composer/semver' => array('pretty_version' => '3.3.2', 'version' => '3.3.2.0', 'reference' => '3953f23262f2bff1919fc82183ad9acb13ff62c9', 'type' => 'library', 'install_path' => __DIR__ . '/./semver', 'aliases' => array(), 'dev_requirement' => \false), 'doctrine/instantiator' => array('pretty_version' => '1.4.1', 'version' => '1.4.1.0', 'reference' => '10dcfce151b967d20fde1b34ae6640712c3891bc', 'type' => 'library', 'install_path' => __DIR__ . '/../doctrine/instantiator', 'aliases' => array(), 'dev_requirement' => \true), 'ergebnis/composer-normalize' => array('pretty_version' => '2.29.0', 'version' => '2.29.0.0', 'reference' => 'fad0e99b16c625817a5bfd910e4d7e31999c53b2', 'type' => 'composer-plugin', 'install_path' => __DIR__ . '/../ergebnis/composer-normalize', 'aliases' => array(), 'dev_requirement' => \true), 'ergebnis/json-normalizer' => array('pretty_version' => '2.1.0', 'version' => '2.1.0.0', 'reference' => '2039eb11131a243b9204bf51219baa08935e6b1d', 'type' => 'library', 'install_path' => __DIR__ . '/../ergebnis/json-normalizer', 'aliases' => array(), 'dev_requirement' => \true), 'ergebnis/json-printer' => array('pretty_version' => '3.3.0', 'version' => '3.3.0.0', 'reference' => '18920367473b099633f644f0ca6dc8794345148f', 'type' => 'library', 'install_path' => __DIR__ . '/../ergebnis/json-printer', 'aliases' => array(), 'dev_requirement' => \true), 'ergebnis/json-schema-validator' => array('pretty_version' => '2.0.0', 'version' => '2.0.0.0', 'reference' => 'dacd8a47c1cc2c426ec71e952da3609ebe901fac', 'type' => 'library', 'install_path' => __DIR__ . '/../ergebnis/json-schema-validator', 'aliases' => array(), 'dev_requirement' => \true), 'fidry/makefile' => array('pretty_version' => '0.2.1', 'version' => '0.2.1.0', 'reference' => '50abe0df37018458b1ab355e56063618d5ba8d10', 'type' => 'library', 'install_path' => __DIR__ . '/../fidry/makefile', 'aliases' => array(), 'dev_requirement' => \true), 'humbug/requirement-checker' => array('pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => 'e787e608c1fb149aeb2b77e2fc76eeb2ab0f8be1', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), 'dev_requirement' => \false), 'justinrainbow/json-schema' => array('pretty_version' => '5.2.12', 'version' => '5.2.12.0', 'reference' => 'ad87d5a5ca981228e0e205c2bc7dfb8e24559b60', 'type' => 'library', 'install_path' => __DIR__ . '/../justinrainbow/json-schema', 'aliases' => array(), 'dev_requirement' => \true), 'localheinz/diff' => array('pretty_version' => '1.1.1', 'version' => '1.1.1.0', 'reference' => '851bb20ea8358c86f677f5f111c4ab031b1c764c', 'type' => 'library', 'install_path' => __DIR__ . '/../localheinz/diff', 'aliases' => array(), 'dev_requirement' => \true), 'myclabs/deep-copy' => array('pretty_version' => '1.11.0', 'version' => '1.11.0.0', 'reference' => '14daed4296fae74d9e3201d2c4925d1acb7aa614', 'type' => 'library', 'install_path' => __DIR__ . '/../myclabs/deep-copy', 'aliases' => array(), 'dev_requirement' => \true), 'nikic/php-parser' => array('pretty_version' => 'v4.14.0', 'version' => '4.14.0.0', 'reference' => '34bea19b6e03d8153165d8f30bba4c3be86184c1', 'type' => 'library', 'install_path' => __DIR__ . '/../nikic/php-parser', 'aliases' => array(), 'dev_requirement' => \true), 'phar-io/manifest' => array('pretty_version' => '2.0.3', 'version' => '2.0.3.0', 'reference' => '97803eca37d319dfa7826cc2437fc020857acb53', 'type' => 'library', 'install_path' => __DIR__ . '/../phar-io/manifest', 'aliases' => array(), 'dev_requirement' => \true), 'phar-io/version' => array('pretty_version' => '3.2.1', 'version' => '3.2.1.0', 'reference' => '4f7fd7836c6f332bb2933569e566a0d6c4cbed74', 'type' => 'library', 'install_path' => __DIR__ . '/../phar-io/version', 'aliases' => array(), 'dev_requirement' => \true), 'phpdocumentor/reflection-common' => array('pretty_version' => '2.2.0', 'version' => '2.2.0.0', 'reference' => '1d01c49d4ed62f25aa84a747ad35d5a16924662b', 'type' => 'library', 'install_path' => __DIR__ . '/../phpdocumentor/reflection-common', 'aliases' => array(), 'dev_requirement' => \true), 'phpdocumentor/reflection-docblock' => array('pretty_version' => '5.3.0', 'version' => '5.3.0.0', 'reference' => '622548b623e81ca6d78b721c5e029f4ce664f170', 'type' => 'library', 'install_path' => __DIR__ . '/../phpdocumentor/reflection-docblock', 'aliases' => array(), 'dev_requirement' => \true), 'phpdocumentor/type-resolver' => array('pretty_version' => '1.6.1', 'version' => '1.6.1.0', 'reference' => '77a32518733312af16a44300404e945338981de3', 'type' => 'library', 'install_path' => __DIR__ . '/../phpdocumentor/type-resolver', 'aliases' => array(), 'dev_requirement' => \true), 'phpspec/prophecy' => array('pretty_version' => 'v1.15.0', 'version' => '1.15.0.0', 'reference' => 'bbcd7380b0ebf3961ee21409db7b38bc31d69a13', 'type' => 'library', 'install_path' => __DIR__ . '/../phpspec/prophecy', 'aliases' => array(), 'dev_requirement' => \true), 'phpunit/php-code-coverage' => array('pretty_version' => '9.2.15', 'version' => '9.2.15.0', 'reference' => '2e9da11878c4202f97915c1cb4bb1ca318a63f5f', 'type' => 'library', 'install_path' => __DIR__ . '/../phpunit/php-code-coverage', 'aliases' => array(), 'dev_requirement' => \true), 'phpunit/php-file-iterator' => array('pretty_version' => '3.0.6', 'version' => '3.0.6.0', 'reference' => 'cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf', 'type' => 'library', 'install_path' => __DIR__ . '/../phpunit/php-file-iterator', 'aliases' => array(), 'dev_requirement' => \true), 'phpunit/php-invoker' => array('pretty_version' => '3.1.1', 'version' => '3.1.1.0', 'reference' => '5a10147d0aaf65b58940a0b72f71c9ac0423cc67', 'type' => 'library', 'install_path' => __DIR__ . '/../phpunit/php-invoker', 'aliases' => array(), 'dev_requirement' => \true), 'phpunit/php-text-template' => array('pretty_version' => '2.0.4', 'version' => '2.0.4.0', 'reference' => '5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28', 'type' => 'library', 'install_path' => __DIR__ . '/../phpunit/php-text-template', 'aliases' => array(), 'dev_requirement' => \true), 'phpunit/php-timer' => array('pretty_version' => '5.0.3', 'version' => '5.0.3.0', 'reference' => '5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2', 'type' => 'library', 'install_path' => __DIR__ . '/../phpunit/php-timer', 'aliases' => array(), 'dev_requirement' => \true), 'phpunit/phpunit' => array('pretty_version' => '9.5.21', 'version' => '9.5.21.0', 'reference' => '0e32b76be457de00e83213528f6bb37e2a38fcb1', 'type' => 'library', 'install_path' => __DIR__ . '/../phpunit/phpunit', 'aliases' => array(), 'dev_requirement' => \true), 'sebastian/cli-parser' => array('pretty_version' => '1.0.1', 'version' => '1.0.1.0', 'reference' => '442e7c7e687e42adc03470c7b668bc4b2402c0b2', 'type' => 'library', 'install_path' => __DIR__ . '/../sebastian/cli-parser', 'aliases' => array(), 'dev_requirement' => \true), 'sebastian/code-unit' => array('pretty_version' => '1.0.8', 'version' => '1.0.8.0', 'reference' => '1fc9f64c0927627ef78ba436c9b17d967e68e120', 'type' => 'library', 'install_path' => __DIR__ . '/../sebastian/code-unit', 'aliases' => array(), 'dev_requirement' => \true), 'sebastian/code-unit-reverse-lookup' => array('pretty_version' => '2.0.3', 'version' => '2.0.3.0', 'reference' => 'ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5', 'type' => 'library', 'install_path' => __DIR__ . '/../sebastian/code-unit-reverse-lookup', 'aliases' => array(), 'dev_requirement' => \true), 'sebastian/comparator' => array('pretty_version' => '4.0.6', 'version' => '4.0.6.0', 'reference' => '55f4261989e546dc112258c7a75935a81a7ce382', 'type' => 'library', 'install_path' => __DIR__ . '/../sebastian/comparator', 'aliases' => array(), 'dev_requirement' => \true), 'sebastian/complexity' => array('pretty_version' => '2.0.2', 'version' => '2.0.2.0', 'reference' => '739b35e53379900cc9ac327b2147867b8b6efd88', 'type' => 'library', 'install_path' => __DIR__ . '/../sebastian/complexity', 'aliases' => array(), 'dev_requirement' => \true), 'sebastian/diff' => array('pretty_version' => '4.0.4', 'version' => '4.0.4.0', 'reference' => '3461e3fccc7cfdfc2720be910d3bd73c69be590d', 'type' => 'library', 'install_path' => __DIR__ . '/../sebastian/diff', 'aliases' => array(), 'dev_requirement' => \true), 'sebastian/environment' => array('pretty_version' => '5.1.4', 'version' => '5.1.4.0', 'reference' => '1b5dff7bb151a4db11d49d90e5408e4e938270f7', 'type' => 'library', 'install_path' => __DIR__ . '/../sebastian/environment', 'aliases' => array(), 'dev_requirement' => \true), 'sebastian/exporter' => array('pretty_version' => '4.0.4', 'version' => '4.0.4.0', 'reference' => '65e8b7db476c5dd267e65eea9cab77584d3cfff9', 'type' => 'library', 'install_path' => __DIR__ . '/../sebastian/exporter', 'aliases' => array(), 'dev_requirement' => \true), 'sebastian/global-state' => array('pretty_version' => '5.0.5', 'version' => '5.0.5.0', 'reference' => '0ca8db5a5fc9c8646244e629625ac486fa286bf2', 'type' => 'library', 'install_path' => __DIR__ . '/../sebastian/global-state', 'aliases' => array(), 'dev_requirement' => \true), 'sebastian/lines-of-code' => array('pretty_version' => '1.0.3', 'version' => '1.0.3.0', 'reference' => 'c1c2e997aa3146983ed888ad08b15470a2e22ecc', 'type' => 'library', 'install_path' => __DIR__ . '/../sebastian/lines-of-code', 'aliases' => array(), 'dev_requirement' => \true), 'sebastian/object-enumerator' => array('pretty_version' => '4.0.4', 'version' => '4.0.4.0', 'reference' => '5c9eeac41b290a3712d88851518825ad78f45c71', 'type' => 'library', 'install_path' => __DIR__ . '/../sebastian/object-enumerator', 'aliases' => array(), 'dev_requirement' => \true), 'sebastian/object-reflector' => array('pretty_version' => '2.0.4', 'version' => '2.0.4.0', 'reference' => 'b4f479ebdbf63ac605d183ece17d8d7fe49c15c7', 'type' => 'library', 'install_path' => __DIR__ . '/../sebastian/object-reflector', 'aliases' => array(), 'dev_requirement' => \true), 'sebastian/recursion-context' => array('pretty_version' => '4.0.4', 'version' => '4.0.4.0', 'reference' => 'cd9d8cf3c5804de4341c283ed787f099f5506172', 'type' => 'library', 'install_path' => __DIR__ . '/../sebastian/recursion-context', 'aliases' => array(), 'dev_requirement' => \true), 'sebastian/resource-operations' => array('pretty_version' => '3.0.3', 'version' => '3.0.3.0', 'reference' => '0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8', 'type' => 'library', 'install_path' => __DIR__ . '/../sebastian/resource-operations', 'aliases' => array(), 'dev_requirement' => \true), 'sebastian/type' => array('pretty_version' => '3.0.0', 'version' => '3.0.0.0', 'reference' => 'b233b84bc4465aff7b57cf1c4bc75c86d00d6dad', 'type' => 'library', 'install_path' => __DIR__ . '/../sebastian/type', 'aliases' => array(), 'dev_requirement' => \true), 'sebastian/version' => array('pretty_version' => '3.0.2', 'version' => '3.0.2.0', 'reference' => 'c6c1022351a901512170118436c764e473f6de8c', 'type' => 'library', 'install_path' => __DIR__ . '/../sebastian/version', 'aliases' => array(), 'dev_requirement' => \true), 'symfony/polyfill-php80' => array('pretty_version' => 'v1.27.0', 'version' => '1.27.0.0', 'reference' => '7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/polyfill-php80', 'aliases' => array(), 'dev_requirement' => \true), 'symfony/polyfill-php81' => array('pretty_version' => 'v1.27.0', 'version' => '1.27.0.0', 'reference' => '707403074c8ea6e2edaf8794b0157a0bfa52157a', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/polyfill-php81', 'aliases' => array(), 'dev_requirement' => \true), 'thecodingmachine/safe' => array('pretty_version' => 'v2.4.0', 'version' => '2.4.0.0', 'reference' => 'e788f3d09dcd36f806350aedb77eac348fafadd3', 'type' => 'library', 'install_path' => __DIR__ . '/../thecodingmachine/safe', 'aliases' => array(), 'dev_requirement' => \true), 'theseer/tokenizer' => array('pretty_version' => '1.2.1', 'version' => '1.2.1.0', 'reference' => '34a41e998c2183e22995f158c581e7b5e755ab9e', 'type' => 'library', 'install_path' => __DIR__ . '/../theseer/tokenizer', 'aliases' => array(), 'dev_requirement' => \true), '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' => \true))); +return array('root' => array('name' => 'humbug/requirement-checker', 'pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => 'ce244bb2d6c3e030748d4b5e5f23c618a5d0d85e', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), 'dev' => \true), 'versions' => array('composer/semver' => array('pretty_version' => '3.3.2', 'version' => '3.3.2.0', 'reference' => '3953f23262f2bff1919fc82183ad9acb13ff62c9', 'type' => 'library', 'install_path' => __DIR__ . '/./semver', 'aliases' => array(), 'dev_requirement' => \false), 'doctrine/instantiator' => array('pretty_version' => '1.4.1', 'version' => '1.4.1.0', 'reference' => '10dcfce151b967d20fde1b34ae6640712c3891bc', 'type' => 'library', 'install_path' => __DIR__ . '/../doctrine/instantiator', 'aliases' => array(), 'dev_requirement' => \true), 'ergebnis/composer-normalize' => array('pretty_version' => '2.29.0', 'version' => '2.29.0.0', 'reference' => 'fad0e99b16c625817a5bfd910e4d7e31999c53b2', 'type' => 'composer-plugin', 'install_path' => __DIR__ . '/../ergebnis/composer-normalize', 'aliases' => array(), 'dev_requirement' => \true), 'ergebnis/json-normalizer' => array('pretty_version' => '2.1.0', 'version' => '2.1.0.0', 'reference' => '2039eb11131a243b9204bf51219baa08935e6b1d', 'type' => 'library', 'install_path' => __DIR__ . '/../ergebnis/json-normalizer', 'aliases' => array(), 'dev_requirement' => \true), 'ergebnis/json-printer' => array('pretty_version' => '3.3.0', 'version' => '3.3.0.0', 'reference' => '18920367473b099633f644f0ca6dc8794345148f', 'type' => 'library', 'install_path' => __DIR__ . '/../ergebnis/json-printer', 'aliases' => array(), 'dev_requirement' => \true), 'ergebnis/json-schema-validator' => array('pretty_version' => '2.0.0', 'version' => '2.0.0.0', 'reference' => 'dacd8a47c1cc2c426ec71e952da3609ebe901fac', 'type' => 'library', 'install_path' => __DIR__ . '/../ergebnis/json-schema-validator', 'aliases' => array(), 'dev_requirement' => \true), 'fidry/makefile' => array('pretty_version' => '0.2.1', 'version' => '0.2.1.0', 'reference' => '50abe0df37018458b1ab355e56063618d5ba8d10', 'type' => 'library', 'install_path' => __DIR__ . '/../fidry/makefile', 'aliases' => array(), 'dev_requirement' => \true), 'humbug/requirement-checker' => array('pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => 'ce244bb2d6c3e030748d4b5e5f23c618a5d0d85e', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), 'dev_requirement' => \false), 'justinrainbow/json-schema' => array('pretty_version' => '5.2.12', 'version' => '5.2.12.0', 'reference' => 'ad87d5a5ca981228e0e205c2bc7dfb8e24559b60', 'type' => 'library', 'install_path' => __DIR__ . '/../justinrainbow/json-schema', 'aliases' => array(), 'dev_requirement' => \true), 'localheinz/diff' => array('pretty_version' => '1.1.1', 'version' => '1.1.1.0', 'reference' => '851bb20ea8358c86f677f5f111c4ab031b1c764c', 'type' => 'library', 'install_path' => __DIR__ . '/../localheinz/diff', 'aliases' => array(), 'dev_requirement' => \true), 'myclabs/deep-copy' => array('pretty_version' => '1.11.0', 'version' => '1.11.0.0', 'reference' => '14daed4296fae74d9e3201d2c4925d1acb7aa614', 'type' => 'library', 'install_path' => __DIR__ . '/../myclabs/deep-copy', 'aliases' => array(), 'dev_requirement' => \true), 'nikic/php-parser' => array('pretty_version' => 'v4.14.0', 'version' => '4.14.0.0', 'reference' => '34bea19b6e03d8153165d8f30bba4c3be86184c1', 'type' => 'library', 'install_path' => __DIR__ . '/../nikic/php-parser', 'aliases' => array(), 'dev_requirement' => \true), 'phar-io/manifest' => array('pretty_version' => '2.0.3', 'version' => '2.0.3.0', 'reference' => '97803eca37d319dfa7826cc2437fc020857acb53', 'type' => 'library', 'install_path' => __DIR__ . '/../phar-io/manifest', 'aliases' => array(), 'dev_requirement' => \true), 'phar-io/version' => array('pretty_version' => '3.2.1', 'version' => '3.2.1.0', 'reference' => '4f7fd7836c6f332bb2933569e566a0d6c4cbed74', 'type' => 'library', 'install_path' => __DIR__ . '/../phar-io/version', 'aliases' => array(), 'dev_requirement' => \true), 'phpdocumentor/reflection-common' => array('pretty_version' => '2.2.0', 'version' => '2.2.0.0', 'reference' => '1d01c49d4ed62f25aa84a747ad35d5a16924662b', 'type' => 'library', 'install_path' => __DIR__ . '/../phpdocumentor/reflection-common', 'aliases' => array(), 'dev_requirement' => \true), 'phpdocumentor/reflection-docblock' => array('pretty_version' => '5.3.0', 'version' => '5.3.0.0', 'reference' => '622548b623e81ca6d78b721c5e029f4ce664f170', 'type' => 'library', 'install_path' => __DIR__ . '/../phpdocumentor/reflection-docblock', 'aliases' => array(), 'dev_requirement' => \true), 'phpdocumentor/type-resolver' => array('pretty_version' => '1.6.1', 'version' => '1.6.1.0', 'reference' => '77a32518733312af16a44300404e945338981de3', 'type' => 'library', 'install_path' => __DIR__ . '/../phpdocumentor/type-resolver', 'aliases' => array(), 'dev_requirement' => \true), 'phpspec/prophecy' => array('pretty_version' => 'v1.15.0', 'version' => '1.15.0.0', 'reference' => 'bbcd7380b0ebf3961ee21409db7b38bc31d69a13', 'type' => 'library', 'install_path' => __DIR__ . '/../phpspec/prophecy', 'aliases' => array(), 'dev_requirement' => \true), 'phpunit/php-code-coverage' => array('pretty_version' => '9.2.15', 'version' => '9.2.15.0', 'reference' => '2e9da11878c4202f97915c1cb4bb1ca318a63f5f', 'type' => 'library', 'install_path' => __DIR__ . '/../phpunit/php-code-coverage', 'aliases' => array(), 'dev_requirement' => \true), 'phpunit/php-file-iterator' => array('pretty_version' => '3.0.6', 'version' => '3.0.6.0', 'reference' => 'cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf', 'type' => 'library', 'install_path' => __DIR__ . '/../phpunit/php-file-iterator', 'aliases' => array(), 'dev_requirement' => \true), 'phpunit/php-invoker' => array('pretty_version' => '3.1.1', 'version' => '3.1.1.0', 'reference' => '5a10147d0aaf65b58940a0b72f71c9ac0423cc67', 'type' => 'library', 'install_path' => __DIR__ . '/../phpunit/php-invoker', 'aliases' => array(), 'dev_requirement' => \true), 'phpunit/php-text-template' => array('pretty_version' => '2.0.4', 'version' => '2.0.4.0', 'reference' => '5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28', 'type' => 'library', 'install_path' => __DIR__ . '/../phpunit/php-text-template', 'aliases' => array(), 'dev_requirement' => \true), 'phpunit/php-timer' => array('pretty_version' => '5.0.3', 'version' => '5.0.3.0', 'reference' => '5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2', 'type' => 'library', 'install_path' => __DIR__ . '/../phpunit/php-timer', 'aliases' => array(), 'dev_requirement' => \true), 'phpunit/phpunit' => array('pretty_version' => '9.5.21', 'version' => '9.5.21.0', 'reference' => '0e32b76be457de00e83213528f6bb37e2a38fcb1', 'type' => 'library', 'install_path' => __DIR__ . '/../phpunit/phpunit', 'aliases' => array(), 'dev_requirement' => \true), 'sebastian/cli-parser' => array('pretty_version' => '1.0.1', 'version' => '1.0.1.0', 'reference' => '442e7c7e687e42adc03470c7b668bc4b2402c0b2', 'type' => 'library', 'install_path' => __DIR__ . '/../sebastian/cli-parser', 'aliases' => array(), 'dev_requirement' => \true), 'sebastian/code-unit' => array('pretty_version' => '1.0.8', 'version' => '1.0.8.0', 'reference' => '1fc9f64c0927627ef78ba436c9b17d967e68e120', 'type' => 'library', 'install_path' => __DIR__ . '/../sebastian/code-unit', 'aliases' => array(), 'dev_requirement' => \true), 'sebastian/code-unit-reverse-lookup' => array('pretty_version' => '2.0.3', 'version' => '2.0.3.0', 'reference' => 'ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5', 'type' => 'library', 'install_path' => __DIR__ . '/../sebastian/code-unit-reverse-lookup', 'aliases' => array(), 'dev_requirement' => \true), 'sebastian/comparator' => array('pretty_version' => '4.0.6', 'version' => '4.0.6.0', 'reference' => '55f4261989e546dc112258c7a75935a81a7ce382', 'type' => 'library', 'install_path' => __DIR__ . '/../sebastian/comparator', 'aliases' => array(), 'dev_requirement' => \true), 'sebastian/complexity' => array('pretty_version' => '2.0.2', 'version' => '2.0.2.0', 'reference' => '739b35e53379900cc9ac327b2147867b8b6efd88', 'type' => 'library', 'install_path' => __DIR__ . '/../sebastian/complexity', 'aliases' => array(), 'dev_requirement' => \true), 'sebastian/diff' => array('pretty_version' => '4.0.4', 'version' => '4.0.4.0', 'reference' => '3461e3fccc7cfdfc2720be910d3bd73c69be590d', 'type' => 'library', 'install_path' => __DIR__ . '/../sebastian/diff', 'aliases' => array(), 'dev_requirement' => \true), 'sebastian/environment' => array('pretty_version' => '5.1.4', 'version' => '5.1.4.0', 'reference' => '1b5dff7bb151a4db11d49d90e5408e4e938270f7', 'type' => 'library', 'install_path' => __DIR__ . '/../sebastian/environment', 'aliases' => array(), 'dev_requirement' => \true), 'sebastian/exporter' => array('pretty_version' => '4.0.4', 'version' => '4.0.4.0', 'reference' => '65e8b7db476c5dd267e65eea9cab77584d3cfff9', 'type' => 'library', 'install_path' => __DIR__ . '/../sebastian/exporter', 'aliases' => array(), 'dev_requirement' => \true), 'sebastian/global-state' => array('pretty_version' => '5.0.5', 'version' => '5.0.5.0', 'reference' => '0ca8db5a5fc9c8646244e629625ac486fa286bf2', 'type' => 'library', 'install_path' => __DIR__ . '/../sebastian/global-state', 'aliases' => array(), 'dev_requirement' => \true), 'sebastian/lines-of-code' => array('pretty_version' => '1.0.3', 'version' => '1.0.3.0', 'reference' => 'c1c2e997aa3146983ed888ad08b15470a2e22ecc', 'type' => 'library', 'install_path' => __DIR__ . '/../sebastian/lines-of-code', 'aliases' => array(), 'dev_requirement' => \true), 'sebastian/object-enumerator' => array('pretty_version' => '4.0.4', 'version' => '4.0.4.0', 'reference' => '5c9eeac41b290a3712d88851518825ad78f45c71', 'type' => 'library', 'install_path' => __DIR__ . '/../sebastian/object-enumerator', 'aliases' => array(), 'dev_requirement' => \true), 'sebastian/object-reflector' => array('pretty_version' => '2.0.4', 'version' => '2.0.4.0', 'reference' => 'b4f479ebdbf63ac605d183ece17d8d7fe49c15c7', 'type' => 'library', 'install_path' => __DIR__ . '/../sebastian/object-reflector', 'aliases' => array(), 'dev_requirement' => \true), 'sebastian/recursion-context' => array('pretty_version' => '4.0.4', 'version' => '4.0.4.0', 'reference' => 'cd9d8cf3c5804de4341c283ed787f099f5506172', 'type' => 'library', 'install_path' => __DIR__ . '/../sebastian/recursion-context', 'aliases' => array(), 'dev_requirement' => \true), 'sebastian/resource-operations' => array('pretty_version' => '3.0.3', 'version' => '3.0.3.0', 'reference' => '0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8', 'type' => 'library', 'install_path' => __DIR__ . '/../sebastian/resource-operations', 'aliases' => array(), 'dev_requirement' => \true), 'sebastian/type' => array('pretty_version' => '3.0.0', 'version' => '3.0.0.0', 'reference' => 'b233b84bc4465aff7b57cf1c4bc75c86d00d6dad', 'type' => 'library', 'install_path' => __DIR__ . '/../sebastian/type', 'aliases' => array(), 'dev_requirement' => \true), 'sebastian/version' => array('pretty_version' => '3.0.2', 'version' => '3.0.2.0', 'reference' => 'c6c1022351a901512170118436c764e473f6de8c', 'type' => 'library', 'install_path' => __DIR__ . '/../sebastian/version', 'aliases' => array(), 'dev_requirement' => \true), 'symfony/polyfill-ctype' => array('pretty_version' => 'v1.27.0', 'version' => '1.27.0.0', 'reference' => '5bbc823adecdae860bb64756d639ecfec17b050a', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/polyfill-ctype', 'aliases' => array(), 'dev_requirement' => \true), 'symfony/polyfill-php80' => array('pretty_version' => 'v1.27.0', 'version' => '1.27.0.0', 'reference' => '7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/polyfill-php80', 'aliases' => array(), 'dev_requirement' => \true), 'symfony/polyfill-php81' => array('pretty_version' => 'v1.27.0', 'version' => '1.27.0.0', 'reference' => '707403074c8ea6e2edaf8794b0157a0bfa52157a', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/polyfill-php81', 'aliases' => array(), 'dev_requirement' => \true), 'symfony/yaml' => array('pretty_version' => 'v6.2.5', 'version' => '6.2.5.0', 'reference' => '2bbfbdacc8a15574f8440c4838ce0d7bb6c86b19', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/yaml', 'aliases' => array(), 'dev_requirement' => \true), 'thecodingmachine/safe' => array('pretty_version' => 'v2.4.0', 'version' => '2.4.0.0', 'reference' => 'e788f3d09dcd36f806350aedb77eac348fafadd3', 'type' => 'library', 'install_path' => __DIR__ . '/../thecodingmachine/safe', 'aliases' => array(), 'dev_requirement' => \true), 'theseer/tokenizer' => array('pretty_version' => '1.2.1', 'version' => '1.2.1.0', 'reference' => '34a41e998c2183e22995f158c581e7b5e755ab9e', 'type' => 'library', 'install_path' => __DIR__ . '/../theseer/tokenizer', 'aliases' => array(), 'dev_requirement' => \true), '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' => \true))); From dd19e45cc1f97d809707ddb45b5814df4a0dbb6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20FIDRY?= Date: Sun, 12 Feb 2023 13:30:09 +0100 Subject: [PATCH 2/2] dump --- .../bin/check-requirements.php | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/res/requirement-checker/bin/check-requirements.php b/res/requirement-checker/bin/check-requirements.php index 2e7d7d6af..d10122705 100644 --- a/res/requirement-checker/bin/check-requirements.php +++ b/res/requirement-checker/bin/check-requirements.php @@ -2,24 +2,19 @@ namespace HumbugBox420\KevinGH\RequirementChecker; -use function gettype; -use function in_array; -use function is_bool; -use function is_string; -use function strtolower; if (isset($_SERVER['BOX_REQUIREMENT_CHECKER'])) { $enableRequirementChecker = $_SERVER['BOX_REQUIREMENT_CHECKER']; - if (is_bool($enableRequirementChecker) && !$enableRequirementChecker) { + if (\is_bool($enableRequirementChecker) && !$enableRequirementChecker) { return; } - if (is_string($enableRequirementChecker) && in_array(strtolower($enableRequirementChecker), ['false', '0'], \true)) { + if (\is_string($enableRequirementChecker) && \in_array(\strtolower($enableRequirementChecker), ['false', '0'], \true)) { return; } - if (!is_bool($enableRequirementChecker) && !is_string($enableRequirementChecker)) { - echo \PHP_EOL . 'Unhandled value type for "BOX_REQUIREMENT_CHECKER". Got "' . gettype($enableRequirementChecker) . '". Proceeding with the requirement checks.' . \PHP_EOL; + if (!\is_bool($enableRequirementChecker) && !\is_string($enableRequirementChecker)) { + echo \PHP_EOL . 'Unhandled value type for "BOX_REQUIREMENT_CHECKER". Got "' . \gettype($enableRequirementChecker) . '". Proceeding with the requirement checks.' . \PHP_EOL; } } -if (\false === in_array(\PHP_SAPI, array('cli', 'phpdbg', 'embed', 'micro'), \true)) { +if (\false === \in_array(\PHP_SAPI, array('cli', 'phpdbg', 'embed', 'micro'), \true)) { echo \PHP_EOL . 'The application may only be invoked from a command line, got "' . \PHP_SAPI . '"' . \PHP_EOL; exit(1); }