Skip to content

Commit

Permalink
refactor: Move PHP settings checker into a class
Browse files Browse the repository at this point in the history
  • Loading branch information
theofidry committed Nov 21, 2023
1 parent 5f28e5b commit 8cb05b5
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 18 deletions.
1 change: 0 additions & 1 deletion src/Console/Command/Compile.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/Console/Command/Extract.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -76,7 +76,7 @@ public function getConfiguration(): Configuration

public function execute(IO $io): int
{
check_php_settings($io);
PhpSettingsChecker::check($io);

Check warning on line 79 in src/Console/Command/Extract.php

View workflow job for this annotation

GitHub Actions / Infection (PHP 8.2)

Escaped Mutant for Mutator "MethodCallRemoval": --- Original +++ New @@ @@ } public function execute(IO $io) : int { - PhpSettingsChecker::check($io); + $pharPath = self::getPharFilePath($io); $outputDir = $io->getTypedArgument(self::OUTPUT_ARG)->asNonEmptyString(); $internal = $io->getTypedOption(self::INTERNAL_OPT)->asBoolean();

$pharPath = self::getPharFilePath($io);
$outputDir = $io->getTypedArgument(self::OUTPUT_ARG)->asNonEmptyString();
Expand Down
4 changes: 2 additions & 2 deletions src/Console/Command/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);

Expand Down
12 changes: 11 additions & 1 deletion src/Console/PhpSettingsChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

declare(strict_types=1);

/*
* This file is part of the box project.
*
* (c) Kevin Herrera <[email protected]>
* Théo Fidry <[email protected]>
*
* 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;
Expand All @@ -24,4 +34,4 @@ public static function check(IO $io): void
),
))->check();
}
}
}
12 changes: 0 additions & 12 deletions src/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down

0 comments on commit 8cb05b5

Please sign in to comment.