diff --git a/requirement-checker/src/Checker.php b/requirement-checker/src/Checker.php index 15b72f323..91c0dc7b1 100644 --- a/requirement-checker/src/Checker.php +++ b/requirement-checker/src/Checker.php @@ -66,12 +66,11 @@ public static function printCheck($checkPassed, Printer $printer, RequirementCol $printer->printv('> Using PHP ', $verbosity); $printer->printvln(PHP_VERSION, $verbosity, 'green'); - $printer->printvln('> PHP is using the following php.ini file:', $verbosity); - if ($iniPath) { + $printer->printvln('> PHP is using the following php.ini file:', $verbosity); $printer->printvln(' '.$iniPath, $verbosity, 'green'); } else { - $printer->printvln(' WARNING: No configuration file (php.ini) used by PHP!', $verbosity, 'yellow'); + $printer->printvln('> PHP is not using any php.ini file.', $verbosity, 'yellow'); } $printer->printvln('', $verbosity); diff --git a/requirement-checker/src/RequirementCollection.php b/requirement-checker/src/RequirementCollection.php index 75d0484ab..f337b09f2 100644 --- a/requirement-checker/src/RequirementCollection.php +++ b/requirement-checker/src/RequirementCollection.php @@ -35,6 +35,21 @@ final class RequirementCollection implements IteratorAggregate, Countable */ private $requirements = []; + /** + * @var string|false + */ + private $phpIniPath; + + /** + * @param string|false|null $phpIniPath + */ + public function __construct($phpIniPath = null) + { + $this->phpIniPath = null === $phpIniPath + ? get_cfg_var('cfg_file_path') + : $phpIniPath; + } + /** * @return Traversable */ @@ -83,7 +98,7 @@ public function getRequirements(): array */ public function getPhpIniPath() { - return get_cfg_var('cfg_file_path'); + return $this->phpIniPath; } /** diff --git a/requirement-checker/tests/CheckerTest.php b/requirement-checker/tests/CheckerTest.php index 9c16f17f7..197d882cd 100644 --- a/requirement-checker/tests/CheckerTest.php +++ b/requirement-checker/tests/CheckerTest.php @@ -85,6 +85,30 @@ public function provideRequirements(): iterable + EOF + ]; + })(); + + yield 'no requirement + no ini path; verbosity=debug' => (static function () use ($phpVersion) { + return [ + new RequirementCollection(false), + IO::VERBOSITY_DEBUG, + true, + << Using PHP {$phpVersion} + > PHP is not using any php.ini file. + + > No requirements found. + + + [OK] Your system is ready to run the application. + + + EOF ]; })();