From 8cb05b5690c13bd59dbf67b359f90b2727999d23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20FIDRY?= Date: Wed, 22 Nov 2023 00:32:46 +0100 Subject: [PATCH] refactor: Move PHP settings checker into a class --- src/Console/Command/Compile.php | 1 - src/Console/Command/Extract.php | 4 ++-- src/Console/Command/Process.php | 4 ++-- src/Console/PhpSettingsChecker.php | 12 +++++++++++- src/functions.php | 12 ------------ 5 files changed, 15 insertions(+), 18 deletions(-) diff --git a/src/Console/Command/Compile.php b/src/Console/Command/Compile.php index 4ab1fcb00..414848372 100644 --- a/src/Console/Command/Compile.php +++ b/src/Console/Command/Compile.php @@ -63,7 +63,6 @@ use function is_callable; use function is_string; use function KevinGH\Box\bump_open_file_descriptor_limit; -use function KevinGH\Box\check_php_settings; use function KevinGH\Box\disable_parallel_processing; use function KevinGH\Box\format_size; use function KevinGH\Box\format_time; diff --git a/src/Console/Command/Extract.php b/src/Console/Command/Extract.php index 0770d9d4a..0d0d999c9 100644 --- a/src/Console/Command/Extract.php +++ b/src/Console/Command/Extract.php @@ -19,6 +19,7 @@ use Fidry\Console\ExitCode; use Fidry\Console\IO; use Fidry\FileSystem\FS; +use KevinGH\Box\Console\PhpSettingsChecker; use KevinGH\Box\Phar\InvalidPhar; use KevinGH\Box\Phar\PharFactory; use KevinGH\Box\Phar\PharMeta; @@ -28,7 +29,6 @@ use Throwable; use function bin2hex; use function file_exists; -use function KevinGH\Box\check_php_settings; use function realpath; use function sprintf; use const DIRECTORY_SEPARATOR; @@ -76,7 +76,7 @@ public function getConfiguration(): Configuration public function execute(IO $io): int { - check_php_settings($io); + PhpSettingsChecker::check($io); $pharPath = self::getPharFilePath($io); $outputDir = $io->getTypedArgument(self::OUTPUT_ARG)->asNonEmptyString(); diff --git a/src/Console/Command/Process.php b/src/Console/Command/Process.php index 775358fe8..473fbf50d 100644 --- a/src/Console/Command/Process.php +++ b/src/Console/Command/Process.php @@ -25,6 +25,7 @@ use KevinGH\Box\Compactor\PhpScoper; use KevinGH\Box\Compactor\Placeholder; use KevinGH\Box\Configuration\Configuration; +use KevinGH\Box\Console\PhpSettingsChecker; use stdClass; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; @@ -38,7 +39,6 @@ use function explode; use function getcwd; use function implode; -use function KevinGH\Box\check_php_settings; use function putenv; use function sprintf; use const KevinGH\Box\BOX_ALLOW_XDEBUG; @@ -89,7 +89,7 @@ public function execute(IO $io): int putenv(BOX_ALLOW_XDEBUG.'=1'); } - check_php_settings($io); + PhpSettingsChecker::check($io); ChangeWorkingDirOption::changeWorkingDirectory($io); diff --git a/src/Console/PhpSettingsChecker.php b/src/Console/PhpSettingsChecker.php index 6bef13f3f..54908a792 100644 --- a/src/Console/PhpSettingsChecker.php +++ b/src/Console/PhpSettingsChecker.php @@ -2,6 +2,16 @@ declare(strict_types=1); +/* + * This file is part of the box project. + * + * (c) Kevin Herrera + * Théo Fidry + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + namespace KevinGH\Box\Console; use Fidry\Console\IO; @@ -24,4 +34,4 @@ public static function check(IO $io): void ), ))->check(); } -} \ No newline at end of file +} diff --git a/src/functions.php b/src/functions.php index 6b8f05019..72fd1845b 100644 --- a/src/functions.php +++ b/src/functions.php @@ -206,18 +206,6 @@ function unique_id(string $prefix): string return $prefix.bin2hex(random_bytes(6)); } -/** - * @private - */ -function check_php_settings(IO $io): void -{ - (new PhpSettingsHandler( - new ConsoleLogger( - $io->getOutput(), - ), - ))->check(); -} - /** * @private */