Skip to content

Commit

Permalink
chore: Migrate to FidryConsole 0.6 (#903)
Browse files Browse the repository at this point in the history
  • Loading branch information
theofidry committed Nov 18, 2023
1 parent 514ff09 commit eba4b11
Show file tree
Hide file tree
Showing 13 changed files with 154 additions and 153 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"require": {
"php": "^8.2",
"fidry/console": "^0.5.0",
"fidry/console": "^0.6.6",
"fidry/filesystem": "^1.1",
"jetbrains/phpstorm-stubs": "^v2022.2",
"nikic/php-parser": "^4.12",
Expand Down
243 changes: 122 additions & 121 deletions composer.lock

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions src/Console/Command/AddPrefixCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
use Fidry\Console\Command\CommandAwareness;
use Fidry\Console\Command\Configuration as CommandConfiguration;
use Fidry\Console\ExitCode;
use Fidry\Console\Input\IO;
use Fidry\Console\IO;
use Humbug\PhpScoper\Configuration\Configuration;
use Humbug\PhpScoper\Configuration\ConfigurationFactory;
use Humbug\PhpScoper\Console\ConfigLoader;
Expand Down Expand Up @@ -165,8 +165,8 @@ public function execute(IO $io): int

private static function getStopOnFailure(IO $io): bool
{
$stopOnFailure = $io->getOption(self::STOP_ON_FAILURE_OPT)->asBoolean();
$continueOnFailure = $io->getOption(self::CONTINUE_ON_FAILURE_OPT)->asBoolean();
$stopOnFailure = $io->getTypedOption(self::STOP_ON_FAILURE_OPT)->asBoolean();
$continueOnFailure = $io->getTypedOption(self::CONTINUE_ON_FAILURE_OPT)->asBoolean();

if ($stopOnFailure) {
$io->info(
Expand Down Expand Up @@ -196,7 +196,7 @@ private static function getStopOnFailure(IO $io): bool
*/
private function getOutputDir(IO $io, Configuration $configuration): string
{
$commandOutputDir = $io->getOption(self::OUTPUT_DIR_OPT)->asString();
$commandOutputDir = $io->getTypedOption(self::OUTPUT_DIR_OPT)->asString();

if ('' !== $commandOutputDir) {
return $commandOutputDir;
Expand Down Expand Up @@ -236,7 +236,7 @@ private static function checkPathIsWriteable(string $path): void

private static function canDeleteOutputDir(IO $io, string $outputDir): bool
{
if ($io->getOption(self::FORCE_OPT)->asBoolean()) {
if ($io->getTypedOption(self::FORCE_OPT)->asBoolean()) {
return true;
}

Expand All @@ -263,8 +263,8 @@ private function retrieveConfig(IO $io, array $paths, string $cwd): Configuratio

return $configLoader->loadConfig(
$io,
$io->getOption(self::PREFIX_OPT)->asString(),
$io->getOption(self::NO_CONFIG_OPT)->asBoolean(),
$io->getTypedOption(self::PREFIX_OPT)->asString(),
$io->getTypedOption(self::NO_CONFIG_OPT)->asBoolean(),
$this->getConfigFilePath($io, $cwd),
ConfigurationFactory::DEFAULT_FILE_NAME,
$this->init,
Expand All @@ -278,7 +278,7 @@ private function retrieveConfig(IO $io, array $paths, string $cwd): Configuratio
*/
private function getConfigFilePath(IO $io, string $cwd): ?string
{
$configFilePath = (string) $io->getOption(self::CONFIG_FILE_OPT)->asNullableString();
$configFilePath = (string) $io->getTypedOption(self::CONFIG_FILE_OPT)->asNullableString();

return '' === $configFilePath ? null : $this->canonicalizePath($configFilePath, $cwd);
}
Expand All @@ -290,7 +290,7 @@ private function getPathArguments(IO $io, string $cwd): array
{
return array_map(
fn (string $path) => $this->canonicalizePath($path, $cwd),
$io->getArgument(self::PATH_ARG)->asNonEmptyStringList(),
$io->getTypedArgument(self::PATH_ARG)->asNonEmptyStringList(),
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/Console/Command/ChangeableDirectory.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

namespace Humbug\PhpScoper\Console\Command;

use Fidry\Console\Input\IO;
use Fidry\Console\IO;
use Humbug\PhpScoper\NotInstantiable;
use InvalidArgumentException;
use Symfony\Component\Console\Exception\RuntimeException;
Expand Down Expand Up @@ -47,7 +47,7 @@ public static function createOption(): InputOption

public static function changeWorkingDirectory(IO $io): void
{
$workingDir = $io->getOption(self::WORKING_DIR_OPT)->asNullableString();
$workingDir = $io->getTypedOption(self::WORKING_DIR_OPT)->asNullableString();

if (null === $workingDir) {
return;
Expand Down
4 changes: 2 additions & 2 deletions src/Console/Command/InitCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

use Fidry\Console\Command\Command;
use Fidry\Console\Command\Configuration as CommandConfiguration;
use Fidry\Console\Input\IO;
use Fidry\Console\IO;
use Symfony\Component\Console\Helper\FormatterHelper;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Filesystem\Filesystem;
Expand Down Expand Up @@ -100,7 +100,7 @@ public function execute(IO $io): int

private function retrieveConfig(IO $io): ?string
{
$configFile = $io->getOption(self::CONFIG_FILE_OPT)->asNullableNonEmptyString();
$configFile = $io->getTypedOption(self::CONFIG_FILE_OPT)->asNullableNonEmptyString();

$configFile = (null === $configFile)
? $this->makeAbsolutePath(self::CONFIG_FILE_DEFAULT)
Expand Down
10 changes: 5 additions & 5 deletions src/Console/Command/InspectCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use Fidry\Console\Command\CommandAwareness;
use Fidry\Console\Command\Configuration as CommandConfiguration;
use Fidry\Console\ExitCode;
use Fidry\Console\Input\IO;
use Fidry\Console\IO;
use Humbug\PhpScoper\Configuration\Configuration;
use Humbug\PhpScoper\Configuration\ConfigurationFactory;
use Humbug\PhpScoper\Console\ConfigLoader;
Expand Down Expand Up @@ -140,8 +140,8 @@ private function retrieveConfig(IO $io, array $paths, string $cwd): Configuratio

return $configLoader->loadConfig(
$io,
$io->getOption(self::PREFIX_OPT)->asString(),
$io->getOption(self::NO_CONFIG_OPT)->asBoolean(),
$io->getTypedOption(self::PREFIX_OPT)->asString(),
$io->getTypedOption(self::NO_CONFIG_OPT)->asBoolean(),
$this->getConfigFilePath($io, $cwd),
ConfigurationFactory::DEFAULT_FILE_NAME,
false,
Expand All @@ -155,7 +155,7 @@ private function retrieveConfig(IO $io, array $paths, string $cwd): Configuratio
*/
private function getConfigFilePath(IO $io, string $cwd): ?string
{
$configFilePath = (string) $io->getOption(self::CONFIG_FILE_OPT)->asNullableString();
$configFilePath = (string) $io->getTypedOption(self::CONFIG_FILE_OPT)->asNullableString();

return '' === $configFilePath ? null : $this->canonicalizePath($configFilePath, $cwd);
}
Expand All @@ -166,7 +166,7 @@ private function getConfigFilePath(IO $io, string $cwd): ?string
private function getFilePath(IO $io, string $cwd): string
{
return $this->canonicalizePath(
$io->getArgument(self::FILE_PATH_ARG)->asNonEmptyString(),
$io->getTypedArgument(self::FILE_PATH_ARG)->asNonEmptyString(),
$cwd,
);
}
Expand Down
10 changes: 5 additions & 5 deletions src/Console/Command/InspectSymbolCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use Fidry\Console\Command\CommandRegistry;
use Fidry\Console\Command\Configuration as CommandConfiguration;
use Fidry\Console\ExitCode;
use Fidry\Console\Input\IO;
use Fidry\Console\IO;
use Humbug\PhpScoper\Configuration\Configuration;
use Humbug\PhpScoper\Configuration\ConfigurationFactory;
use Humbug\PhpScoper\Console\ConfigLoader;
Expand Down Expand Up @@ -108,7 +108,7 @@ public function execute(IO $io): int
// working directory
$cwd = getcwd();

$symbol = $io->getArgument(self::SYMBOL_ARG)->asString();
$symbol = $io->getTypedArgument(self::SYMBOL_ARG)->asString();
$symbolType = self::getSymbolType($io);
$config = $this->retrieveConfig($io, $cwd);

Expand All @@ -130,7 +130,7 @@ public function execute(IO $io): int
// TODO: https://github.com/theofidry/console/issues/99
private static function getSymbolType(IO $io): SymbolType
{
$symbolType = $io->getArgument(self::SYMBOL_TYPE_ARG)->asString();
$symbolType = $io->getTypedArgument(self::SYMBOL_TYPE_ARG)->asString();

return SymbolType::from($symbolType);
}
Expand All @@ -144,7 +144,7 @@ private function retrieveConfig(IO $io, string $cwd): Configuration
);

$configFilePath = $this->getConfigFilePath($io, $cwd);
$noConfig = $io->getOption(self::NO_CONFIG_OPT)->asBoolean();
$noConfig = $io->getTypedOption(self::NO_CONFIG_OPT)->asBoolean();

if (null === $configFilePath) {
// Unlike when scoping, we do not want a config file to be created
Expand Down Expand Up @@ -175,7 +175,7 @@ private function retrieveConfig(IO $io, string $cwd): Configuration
*/
private function getConfigFilePath(IO $io, string $cwd): ?string
{
$configPath = (string) $io->getOption(self::CONFIG_FILE_OPT)->asNullableString();
$configPath = (string) $io->getTypedOption(self::CONFIG_FILE_OPT)->asNullableString();

if ('' === $configPath) {
$configPath = ConfigurationFactory::DEFAULT_FILE_NAME;
Expand Down
2 changes: 1 addition & 1 deletion src/Console/ConfigLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
namespace Humbug\PhpScoper\Console;

use Fidry\Console\Command\CommandRegistry;
use Fidry\Console\Input\IO;
use Fidry\Console\IO;
use Humbug\PhpScoper\Configuration\Configuration;
use Humbug\PhpScoper\Configuration\ConfigurationFactory;
use Symfony\Component\Console\Exception\RuntimeException;
Expand Down
2 changes: 1 addition & 1 deletion src/Console/ConsoleScoper.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
namespace Humbug\PhpScoper\Console;

use Fidry\Console\Application\Application;
use Fidry\Console\Input\IO;
use Fidry\Console\IO;
use Humbug\PhpScoper\Autoload\ComposerFileHasher;
use Humbug\PhpScoper\Autoload\ScoperAutoloadGenerator;
use Humbug\PhpScoper\Configuration\Configuration;
Expand Down
2 changes: 1 addition & 1 deletion src/Console/ScoperLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
namespace Humbug\PhpScoper\Console;

use Fidry\Console\Application\Application as FidryApplication;
use Fidry\Console\Input\IO;
use Fidry\Console\IO;
use Humbug\PhpScoper\Throwable\Exception\ParsingException;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Output\NullOutput;
Expand Down
4 changes: 2 additions & 2 deletions tests/Console/Command/AddPrefixCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

namespace Humbug\PhpScoper\Console\Command;

use Fidry\Console\Application\SymfonyApplication;
use Fidry\Console\Command\SymfonyCommand;
use Fidry\Console\Bridge\Application\SymfonyApplication;
use Fidry\Console\Bridge\Command\SymfonyCommand;
use Fidry\FileSystem\FS;
use Humbug\PhpScoper\Configuration\ConfigurationFactory;
use Humbug\PhpScoper\Configuration\RegexChecker;
Expand Down
4 changes: 2 additions & 2 deletions tests/Console/Command/AppIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

namespace Humbug\PhpScoper\Console\Command;

use Fidry\Console\Application\SymfonyApplication;
use Fidry\Console\Command\SymfonyCommand;
use Fidry\Console\Bridge\Application\SymfonyApplication;
use Fidry\Console\Bridge\Command\SymfonyCommand;
use Humbug\PhpScoper\Configuration\ConfigurationFactory;
use Humbug\PhpScoper\Configuration\RegexChecker;
use Humbug\PhpScoper\Configuration\SymbolsConfigurationFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

namespace Humbug\PhpScoper\Console\Command;

use Fidry\Console\Application\SymfonyApplication;
use Fidry\Console\Bridge\Application\SymfonyApplication;
use Fidry\Console\DisplayNormalizer;
use Humbug\PhpScoper\Console\Application;
use Humbug\PhpScoper\Container;
Expand Down

0 comments on commit eba4b11

Please sign in to comment.