Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Add the Command prefix to the console command class names #1326

Merged
merged 1 commit into from
Mar 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 25 additions & 25 deletions src/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@
namespace KevinGH\Box\Console;

use Fidry\Console\Application\Application as FidryApplication;
use KevinGH\Box\Console\Command\Check\Signature as CheckSignature;
use KevinGH\Box\Console\Command\Compile;
use KevinGH\Box\Console\Command\Composer\ComposerCheckVersion;
use KevinGH\Box\Console\Command\Composer\ComposerVendorDir;
use KevinGH\Box\Console\Command\Diff;
use KevinGH\Box\Console\Command\Extract;
use KevinGH\Box\Console\Command\GenerateDockerFile;
use KevinGH\Box\Console\Command\Info;
use KevinGH\Box\Console\Command\Info\Signature as InfoSignature;
use KevinGH\Box\Console\Command\Namespace_;
use KevinGH\Box\Console\Command\Process;
use KevinGH\Box\Console\Command\Validate;
use KevinGH\Box\Console\Command\Verify;
use KevinGH\Box\Console\Command\Check\CheckSignatureCommand as CheckSignature;
use KevinGH\Box\Console\Command\CompileCommand;
use KevinGH\Box\Console\Command\Composer\ComposerCheckVersionCommand;
use KevinGH\Box\Console\Command\Composer\ComposerVendorDirCommand;
use KevinGH\Box\Console\Command\DiffCommand;
use KevinGH\Box\Console\Command\ExtractCommand;
use KevinGH\Box\Console\Command\GenerateDockerFileCommand;
use KevinGH\Box\Console\Command\Info\InfoSignatureCommand as InfoSignature;
use KevinGH\Box\Console\Command\InfoCommand;
use KevinGH\Box\Console\Command\NamespaceCommand;
use KevinGH\Box\Console\Command\ProcessCommand;
use KevinGH\Box\Console\Command\ValidateCommand;
use KevinGH\Box\Console\Command\VerifyCommand;
use KevinGH\Box\RequirementChecker\AppRequirementsFactory;
use KevinGH\Box\RequirementChecker\RequirementsDumper;
use function KevinGH\Box\get_box_version;
Expand Down Expand Up @@ -93,25 +93,25 @@ public function getHeader(): string
public function getCommands(): array
{
return [
new ComposerCheckVersion(),
new ComposerVendorDir(),
new Compile(
new ComposerCheckVersionCommand(),
new ComposerVendorDirCommand(),
new CompileCommand(
$this->getHeader(),
new RequirementsDumper(
new AppRequirementsFactory(),
),
),
new Diff(),
new Info(),
new Info('info:general'),
new DiffCommand(),
new InfoCommand(),
new InfoCommand('info:general'),
new InfoSignature(),
new CheckSignature(),
new Process(),
new Extract(),
new Validate(),
new Verify(),
new GenerateDockerFile(),
new Namespace_(),
new ProcessCommand(),
new ExtractCommand(),
new ValidateCommand(),
new VerifyCommand(),
new GenerateDockerFileCommand(),
new NamespaceCommand(),
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
/**
* @private
*/
final class Signature implements Command
final class CheckSignatureCommand implements Command
{
private const PHAR_ARG = 'phar';
private const HASH = 'hash';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
/**
* @private
*/
final class Compile implements CommandAware
final class CompileCommand implements CommandAware
{
use CommandAwareness;

Expand Down Expand Up @@ -997,6 +997,6 @@ private function generateDockerFile(IO $io): int

private function getDockerCommand(): Command
{
return $this->getCommandRegistry()->findCommand(GenerateDockerFile::NAME);
return $this->getCommandRegistry()->findCommand(GenerateDockerFileCommand::NAME);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
/**
* @private
*/
final class ComposerCheckVersion extends ComposerCommand
final class ComposerCheckVersionCommand extends ComposerCommand
{
public function getConfiguration(): Configuration
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
/**
* @private
*/
final class ComposerVendorDir extends ComposerCommand
final class ComposerVendorDirCommand extends ComposerCommand
{
public function getConfiguration(): Configuration
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
/**
* @private
*/
final class Diff implements Command
final class DiffCommand implements Command
{
private const FIRST_PHAR_ARG = 'pharA';
private const SECOND_PHAR_ARG = 'pharB';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
/**
* @private
*/
final class Extract implements Command
final class ExtractCommand implements Command
{
public const STUB_PATH = '.phar/stub.php';
public const PHAR_META_PATH = '.phar/meta.json';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
/**
* @private
*/
final class GenerateDockerFile implements CommandAware
final class GenerateDockerFileCommand implements CommandAware
{
use CommandAwareness;

Expand Down Expand Up @@ -144,10 +144,10 @@ private function guessPharPath(IO $io): ?string
return $config->getOutputPath();
}

private function getCompileCommand(): Compile
private function getCompileCommand(): CompileCommand
{
/* @noinspection PhpIncompatibleReturnTypeInspection */
return $this->getCommandRegistry()->findCommand(Compile::NAME);
return $this->getCommandRegistry()->findCommand(CompileCommand::NAME);
}

private static function createCompileInput(IO $io): InputInterface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
/**
* @private
*/
final class Signature implements Command
final class InfoSignatureCommand implements Command
{
private const PHAR_ARG = 'phar';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
/**
* @private
*/
final readonly class Info implements Command
final readonly class InfoCommand implements Command
{
private const PHAR_ARG = 'phar';
private const LIST_OPT = 'list';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
use function current;
use function explode;

final class Namespace_ implements Command
final class NamespaceCommand implements Command
{
public function getConfiguration(): Configuration
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
use function sprintf;

// TODO: replace the PHP-Scoper compactor in order to warn the user about scoping errors
final class Process implements Command
final class ProcessCommand implements Command
{
private const FILE_ARGUMENT = 'file';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
/**
* @private
*/
final class Validate implements Command
final class ValidateCommand implements Command
{
private const FILE_ARGUMENT = 'file';
private const IGNORE_MESSAGES_OPTION = 'ignore-recommendations-and-warnings';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
/**
* @private
*/
final class Verify implements Command
final class VerifyCommand implements Command
{
private const PHAR_ARG = 'phar';

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

namespace KevinGH\Box\Phar\Differ;

use KevinGH\Box\Console\Command\Extract;
use KevinGH\Box\Console\Command\ExtractCommand;
use KevinGH\Box\Phar\DiffMode;

final class DifferFactory
Expand All @@ -26,7 +26,7 @@ public function create(
return match ($mode) {
DiffMode::FILE_NAME => new FilenameDiffer(),
DiffMode::GIT => new GitDiffer(),
DiffMode::GNU => new ProcessCommandBasedDiffer('diff --exclude='.Extract::PHAR_META_PATH),
DiffMode::GNU => new ProcessCommandBasedDiffer('diff --exclude='.ExtractCommand::PHAR_META_PATH),
DiffMode::CHECKSUM => new ChecksumDiffer($checksumAlgorithm),
};
}
Expand Down
4 changes: 2 additions & 2 deletions src/Phar/Differ/GitDiffer.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
namespace KevinGH\Box\Phar\Differ;

use Fidry\Console\IO;
use KevinGH\Box\Console\Command\Extract;
use KevinGH\Box\Console\Command\ExtractCommand;
use KevinGH\Box\Phar\PharInfo;
use function array_filter;
use function explode;
Expand Down Expand Up @@ -48,7 +48,7 @@ public function diff(PharInfo $pharInfoA, PharInfo $pharInfoB, IO $io): void

$pharMetaLine = sprintf(
'a%2$s/%1$s b%3$s/%1$s',
Extract::PHAR_META_PATH,
ExtractCommand::PHAR_META_PATH,
$pharInfoA->getFileName(),
$pharInfoB->getFileName(),
);
Expand Down
8 changes: 4 additions & 4 deletions src/Phar/PharInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
namespace KevinGH\Box\Phar;

use Fidry\FileSystem\FS;
use KevinGH\Box\Console\Command\Extract;
use KevinGH\Box\Console\Command\ExtractCommand;
use KevinGH\Box\ExecutableFinder;
use KevinGH\Box\Phar\Throwable\InvalidPhar;
use KevinGH\Box\RequirementChecker\Requirement;
Expand Down Expand Up @@ -257,7 +257,7 @@ public function getSignature(): ?array

public function getStubPath(): string
{
return Extract::STUB_PATH;
return ExtractCommand::STUB_PATH;
}

public function getStubContent(): ?string
Expand Down Expand Up @@ -366,8 +366,8 @@ private static function loadDumpedPharFiles(string $tmp): array
),
);

$meta = PharMeta::fromJson(FS::getFileContents($tmp.DIRECTORY_SEPARATOR.Extract::PHAR_META_PATH));
unset($dumpedFiles[Extract::PHAR_META_PATH]);
$meta = PharMeta::fromJson(FS::getFileContents($tmp.DIRECTORY_SEPARATOR.ExtractCommand::PHAR_META_PATH));
unset($dumpedFiles[ExtractCommand::PHAR_META_PATH]);

return [$meta, $dumpedFiles];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@
/**
* @internal
*/
#[CoversClass(Signature::class)]
class SignatureTest extends CommandTestCase
#[CoversClass(CheckSignatureCommand::class)]
class SignatureCommandTest extends CommandTestCase
{
private const FIXTURES = __DIR__.'/../../../../fixtures/phar';

protected function getCommand(): Command
{
return new Signature();
return new CheckSignatureCommand();
}

public function test_it_checks_the_phar_signature(): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@
/**
* @internal
*/
#[CoversClass(Compile::class)]
#[CoversClass(CompileCommand::class)]
#[CoversClass(MessageRenderer::class)]
#[RunTestsInSeparateProcesses]
class CompileTest extends FileSystemTestCase
class CompileCommandTest extends FileSystemTestCase
{
use RequiresPharReadonlyOff;

Expand Down Expand Up @@ -161,7 +161,7 @@ protected function setUp(): void

$application = new SymfonyApplication();
$application->add($command);
$application->add(new SymfonyCommand(new GenerateDockerFile()));
$application->add(new SymfonyCommand(new GenerateDockerFileCommand()));

$this->commandTester = new CommandTester(
$application->get(
Expand All @@ -181,7 +181,7 @@ protected function tearDown(): void

protected function getCommand(): Command
{
return new Compile(
return new CompileCommand(
(new Application())->getHeader(),
new RequirementsDumper(
new AppRequirementsFactory(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@
/**
* @internal
*/
#[CoversClass(ComposerCheckVersion::class)]
class ComposerCheckVersionTest extends TestCase
#[CoversClass(ComposerCheckVersionCommand::class)]
class ComposerCheckVersionCommandTest extends TestCase
{
private CommandTester $commandTester;
private string $cwd;

protected function setUp(): void
{
$this->commandTester = CommandTester::fromConsoleCommand(new ComposerCheckVersion());
$this->commandTester = CommandTester::fromConsoleCommand(new ComposerCheckVersionCommand());

$this->cwd = getcwd();
chdir(__DIR__);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@
/**
* @internal
*/
#[CoversClass(ComposerVendorDir::class)]
class ComposerVendorDirTest extends TestCase
#[CoversClass(ComposerVendorDirCommand::class)]
class ComposerVendorDirCommandTest extends TestCase
{
private CommandTester $commandTester;
private string $cwd;

protected function setUp(): void
{
$this->commandTester = CommandTester::fromConsoleCommand(new ComposerVendorDir());
$this->commandTester = CommandTester::fromConsoleCommand(new ComposerVendorDirCommand());

$this->cwd = getcwd();
chdir(__DIR__);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
/**
* @internal
*/
#[CoversClass(Diff::class)]
class DiffTest extends CommandTestCase
#[CoversClass(DiffCommand::class)]
class DiffCommandTest extends CommandTestCase
{
use RequiresPharReadonlyOff;

Expand All @@ -47,7 +47,7 @@ protected function setUp(): void

protected function getCommand(): Command
{
return new Diff();
return new DiffCommand();
}

#[DataProvider('diffPharsProvider')]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@
/**
* @internal
*/
#[CoversClass(Extract::class)]
#[CoversClass(ExtractCommand::class)]
#[RunTestsInSeparateProcesses]
class ExtractTest extends CommandTestCase
class ExtractCommandTest extends CommandTestCase
{
private const FIXTURES_DIR = __DIR__.'/../../../fixtures/extract';

protected function getCommand(): Command
{
return new Extract();
return new ExtractCommand();
}

#[DataProvider('pharProvider')]
Expand Down
Loading
Loading