@@ -34,98 +34,98 @@ |
||
| 34 | 34 | */ |
| 35 | 35 | final class SymfonyApplication extends BaseSymfonyApplication |
| 36 | 36 | { |
| 37 | - private Application $application; |
|
| 38 | - |
|
| 39 | - public function __construct(Application $application) |
|
| 40 | - { |
|
| 41 | - $this->application = $application; |
|
| 42 | - |
|
| 43 | - parent::__construct( |
|
| 44 | - $application->getName(), |
|
| 45 | - $application->getVersion(), |
|
| 46 | - ); |
|
| 47 | - |
|
| 48 | - $this->setDefaultCommand($application->getDefaultCommand()); |
|
| 49 | - $this->setAutoExit($application->isAutoExitEnabled()); |
|
| 50 | - $this->setCatchExceptions($application->areExceptionsCaught()); |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - public function reset(): void |
|
| 54 | - { |
|
| 55 | - if ($this->application instanceof ResetInterface) { |
|
| 56 | - $this->application->reset(); |
|
| 57 | - } |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - public function setHelperSet(HelperSet $helperSet): void |
|
| 61 | - { |
|
| 62 | - throw new LogicException('Not supported'); |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - public function setDefinition(InputDefinition $definition): void |
|
| 66 | - { |
|
| 67 | - throw new LogicException('Not supported'); |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - public function getHelp(): string |
|
| 71 | - { |
|
| 72 | - return $this->application->getHelp(); |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - public function getLongVersion(): string |
|
| 76 | - { |
|
| 77 | - return $this->application->getLongVersion(); |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - public function setCommandLoader(CommandLoaderInterface $commandLoader): void |
|
| 81 | - { |
|
| 82 | - throw new LogicException('Not supported'); |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - public function setSignalsToDispatchEvent(int ...$signalsToDispatchEvent): void |
|
| 86 | - { |
|
| 87 | - throw new LogicException('Not supported'); |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - public function setName(string $name): void |
|
| 91 | - { |
|
| 92 | - throw new LogicException('Not supported'); |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - public function setVersion(string $version): void |
|
| 96 | - { |
|
| 97 | - throw new LogicException('Not supported'); |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - protected function configureIO(InputInterface $input, OutputInterface $output): void |
|
| 101 | - { |
|
| 102 | - parent::configureIO($input, $output); |
|
| 103 | - |
|
| 104 | - if ($this->application instanceof ConfigurableIO) { |
|
| 105 | - $this->application->configureIO( |
|
| 106 | - new IO($input, $output), |
|
| 107 | - ); |
|
| 108 | - } |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - protected function getDefaultCommands(): array |
|
| 112 | - { |
|
| 113 | - return [ |
|
| 114 | - ...parent::getDefaultCommands(), |
|
| 115 | - ...$this->getSymfonyCommands(), |
|
| 116 | - ]; |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - /** |
|
| 120 | - * @return list<Command> |
|
| 121 | - */ |
|
| 122 | - private function getSymfonyCommands(): array |
|
| 123 | - { |
|
| 124 | - return array_values( |
|
| 125 | - array_map( |
|
| 126 | - static fn (FidryCommand $command) => new SymfonyCommand($command), |
|
| 127 | - $this->application->getCommands(), |
|
| 128 | - ), |
|
| 129 | - ); |
|
| 130 | - } |
|
| 37 | + private Application $application; |
|
| 38 | + |
|
| 39 | + public function __construct(Application $application) |
|
| 40 | + { |
|
| 41 | + $this->application = $application; |
|
| 42 | + |
|
| 43 | + parent::__construct( |
|
| 44 | + $application->getName(), |
|
| 45 | + $application->getVersion(), |
|
| 46 | + ); |
|
| 47 | + |
|
| 48 | + $this->setDefaultCommand($application->getDefaultCommand()); |
|
| 49 | + $this->setAutoExit($application->isAutoExitEnabled()); |
|
| 50 | + $this->setCatchExceptions($application->areExceptionsCaught()); |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + public function reset(): void |
|
| 54 | + { |
|
| 55 | + if ($this->application instanceof ResetInterface) { |
|
| 56 | + $this->application->reset(); |
|
| 57 | + } |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + public function setHelperSet(HelperSet $helperSet): void |
|
| 61 | + { |
|
| 62 | + throw new LogicException('Not supported'); |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + public function setDefinition(InputDefinition $definition): void |
|
| 66 | + { |
|
| 67 | + throw new LogicException('Not supported'); |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + public function getHelp(): string |
|
| 71 | + { |
|
| 72 | + return $this->application->getHelp(); |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + public function getLongVersion(): string |
|
| 76 | + { |
|
| 77 | + return $this->application->getLongVersion(); |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + public function setCommandLoader(CommandLoaderInterface $commandLoader): void |
|
| 81 | + { |
|
| 82 | + throw new LogicException('Not supported'); |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + public function setSignalsToDispatchEvent(int ...$signalsToDispatchEvent): void |
|
| 86 | + { |
|
| 87 | + throw new LogicException('Not supported'); |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + public function setName(string $name): void |
|
| 91 | + { |
|
| 92 | + throw new LogicException('Not supported'); |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + public function setVersion(string $version): void |
|
| 96 | + { |
|
| 97 | + throw new LogicException('Not supported'); |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + protected function configureIO(InputInterface $input, OutputInterface $output): void |
|
| 101 | + { |
|
| 102 | + parent::configureIO($input, $output); |
|
| 103 | + |
|
| 104 | + if ($this->application instanceof ConfigurableIO) { |
|
| 105 | + $this->application->configureIO( |
|
| 106 | + new IO($input, $output), |
|
| 107 | + ); |
|
| 108 | + } |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + protected function getDefaultCommands(): array |
|
| 112 | + { |
|
| 113 | + return [ |
|
| 114 | + ...parent::getDefaultCommands(), |
|
| 115 | + ...$this->getSymfonyCommands(), |
|
| 116 | + ]; |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + /** |
|
| 120 | + * @return list<Command> |
|
| 121 | + */ |
|
| 122 | + private function getSymfonyCommands(): array |
|
| 123 | + { |
|
| 124 | + return array_values( |
|
| 125 | + array_map( |
|
| 126 | + static fn (FidryCommand $command) => new SymfonyCommand($command), |
|
| 127 | + $this->application->getCommands(), |
|
| 128 | + ), |
|
| 129 | + ); |
|
| 130 | + } |
|
| 131 | 131 | } |
@@ -32,8 +32,7 @@ |
||
| 32 | 32 | * Bridge to create a traditional Symfony application from the new Application |
| 33 | 33 | * API. |
| 34 | 34 | */ |
| 35 | -final class SymfonyApplication extends BaseSymfonyApplication |
|
| 36 | -{ |
|
| 35 | +final class SymfonyApplication extends BaseSymfonyApplication { |
|
| 37 | 36 | private Application $application; |
| 38 | 37 | |
| 39 | 38 | public function __construct(Application $application) |
@@ -17,54 +17,54 @@ |
||
| 17 | 17 | |
| 18 | 18 | interface Application |
| 19 | 19 | { |
| 20 | - /** |
|
| 21 | - * Name of the application. Typically shown when running the application |
|
| 22 | - * or displaying the current version. |
|
| 23 | - */ |
|
| 24 | - public function getName(): string; |
|
| 20 | + /** |
|
| 21 | + * Name of the application. Typically shown when running the application |
|
| 22 | + * or displaying the current version. |
|
| 23 | + */ |
|
| 24 | + public function getName(): string; |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Version of the application. |
|
| 28 | - */ |
|
| 29 | - public function getVersion(): string; |
|
| 26 | + /** |
|
| 27 | + * Version of the application. |
|
| 28 | + */ |
|
| 29 | + public function getVersion(): string; |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * Usually a combination of the name and version, typically displayed at |
|
| 33 | - * the beginning when executing a command. |
|
| 34 | - */ |
|
| 35 | - public function getLongVersion(): string; |
|
| 31 | + /** |
|
| 32 | + * Usually a combination of the name and version, typically displayed at |
|
| 33 | + * the beginning when executing a command. |
|
| 34 | + */ |
|
| 35 | + public function getLongVersion(): string; |
|
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * Message usually show when showing the description of a command. |
|
| 39 | - */ |
|
| 40 | - public function getHelp(): string; |
|
| 37 | + /** |
|
| 38 | + * Message usually show when showing the description of a command. |
|
| 39 | + */ |
|
| 40 | + public function getHelp(): string; |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * Exhaustive list of the custom commands. A few more commands such as |
|
| 44 | - * the HelpCommand or ListCommand are also included besides those. |
|
| 45 | - * |
|
| 46 | - * @return Command[] |
|
| 47 | - */ |
|
| 48 | - public function getCommands(): array; |
|
| 42 | + /** |
|
| 43 | + * Exhaustive list of the custom commands. A few more commands such as |
|
| 44 | + * the HelpCommand or ListCommand are also included besides those. |
|
| 45 | + * |
|
| 46 | + * @return Command[] |
|
| 47 | + */ |
|
| 48 | + public function getCommands(): array; |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * The default command executed when the application is being run without |
|
| 52 | - * any command specified. Typically the list command which will display all |
|
| 53 | - * the available commands. |
|
| 54 | - */ |
|
| 55 | - public function getDefaultCommand(): string; |
|
| 50 | + /** |
|
| 51 | + * The default command executed when the application is being run without |
|
| 52 | + * any command specified. Typically the list command which will display all |
|
| 53 | + * the available commands. |
|
| 54 | + */ |
|
| 55 | + public function getDefaultCommand(): string; |
|
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * When enabled the process will stop with the returned exit code. Otherwise |
|
| 59 | - * will simply return the exit code. |
|
| 60 | - */ |
|
| 61 | - public function isAutoExitEnabled(): bool; |
|
| 57 | + /** |
|
| 58 | + * When enabled the process will stop with the returned exit code. Otherwise |
|
| 59 | + * will simply return the exit code. |
|
| 60 | + */ |
|
| 61 | + public function isAutoExitEnabled(): bool; |
|
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * Whether exceptions are caught when executing the application. If yes a CLI |
|
| 65 | - * renderer will render the exception to the output, otherwise the exception |
|
| 66 | - * will be left alone and how the exception is rendered is left to the callee |
|
| 67 | - * (e.g. the regular PHP exception printer). |
|
| 68 | - */ |
|
| 69 | - public function areExceptionsCaught(): bool; |
|
| 63 | + /** |
|
| 64 | + * Whether exceptions are caught when executing the application. If yes a CLI |
|
| 65 | + * renderer will render the exception to the output, otherwise the exception |
|
| 66 | + * will be left alone and how the exception is rendered is left to the callee |
|
| 67 | + * (e.g. the regular PHP exception printer). |
|
| 68 | + */ |
|
| 69 | + public function areExceptionsCaught(): bool; |
|
| 70 | 70 | } |
@@ -15,8 +15,7 @@ |
||
| 15 | 15 | |
| 16 | 16 | use Fidry\Console\Command\Command; |
| 17 | 17 | |
| 18 | -interface Application |
|
| 19 | -{ |
|
| 18 | +interface Application { |
|
| 20 | 19 | /** |
| 21 | 20 | * Name of the application. Typically shown when running the application |
| 22 | 21 | * or displaying the current version. |
@@ -23,36 +23,36 @@ |
||
| 23 | 23 | */ |
| 24 | 24 | abstract class BaseApplication implements Application |
| 25 | 25 | { |
| 26 | - public function getLongVersion(): string |
|
| 27 | - { |
|
| 28 | - if ('UNKNOWN' !== $this->getName()) { |
|
| 29 | - if ('UNKNOWN' !== $this->getVersion()) { |
|
| 30 | - return sprintf('%s <info>%s</info>', $this->getName(), $this->getVersion()); |
|
| 31 | - } |
|
| 32 | - |
|
| 33 | - return $this->getName(); |
|
| 34 | - } |
|
| 35 | - |
|
| 36 | - return 'Console Tool'; |
|
| 37 | - } |
|
| 38 | - |
|
| 39 | - public function getHelp(): string |
|
| 40 | - { |
|
| 41 | - return $this->getLongVersion(); |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - public function getDefaultCommand(): string |
|
| 45 | - { |
|
| 46 | - return 'list'; |
|
| 47 | - } |
|
| 48 | - |
|
| 49 | - public function isAutoExitEnabled(): bool |
|
| 50 | - { |
|
| 51 | - return true; |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - public function areExceptionsCaught(): bool |
|
| 55 | - { |
|
| 56 | - return true; |
|
| 57 | - } |
|
| 26 | + public function getLongVersion(): string |
|
| 27 | + { |
|
| 28 | + if ('UNKNOWN' !== $this->getName()) { |
|
| 29 | + if ('UNKNOWN' !== $this->getVersion()) { |
|
| 30 | + return sprintf('%s <info>%s</info>', $this->getName(), $this->getVersion()); |
|
| 31 | + } |
|
| 32 | + |
|
| 33 | + return $this->getName(); |
|
| 34 | + } |
|
| 35 | + |
|
| 36 | + return 'Console Tool'; |
|
| 37 | + } |
|
| 38 | + |
|
| 39 | + public function getHelp(): string |
|
| 40 | + { |
|
| 41 | + return $this->getLongVersion(); |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + public function getDefaultCommand(): string |
|
| 45 | + { |
|
| 46 | + return 'list'; |
|
| 47 | + } |
|
| 48 | + |
|
| 49 | + public function isAutoExitEnabled(): bool |
|
| 50 | + { |
|
| 51 | + return true; |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + public function areExceptionsCaught(): bool |
|
| 55 | + { |
|
| 56 | + return true; |
|
| 57 | + } |
|
| 58 | 58 | } |
@@ -21,8 +21,7 @@ |
||
| 21 | 21 | * |
| 22 | 22 | * @see \Symfony\Component\Console\Application |
| 23 | 23 | */ |
| 24 | -abstract class BaseApplication implements Application |
|
| 25 | -{ |
|
| 24 | +abstract class BaseApplication implements Application { |
|
| 26 | 25 | public function getLongVersion(): string |
| 27 | 26 | { |
| 28 | 27 | if ('UNKNOWN' !== $this->getName()) { |
@@ -17,9 +17,9 @@ |
||
| 17 | 17 | |
| 18 | 18 | interface ConfigurableIO |
| 19 | 19 | { |
| 20 | - /** |
|
| 21 | - * Configures the input and output instances based on the user arguments and |
|
| 22 | - * options. This is executed before running the application. |
|
| 23 | - */ |
|
| 24 | - public function configureIO(IO $io): void; |
|
| 20 | + /** |
|
| 21 | + * Configures the input and output instances based on the user arguments and |
|
| 22 | + * options. This is executed before running the application. |
|
| 23 | + */ |
|
| 24 | + public function configureIO(IO $io): void; |
|
| 25 | 25 | } |
@@ -15,8 +15,7 @@ |
||
| 15 | 15 | |
| 16 | 16 | use Fidry\Console\IO; |
| 17 | 17 | |
| 18 | -interface ConfigurableIO |
|
| 19 | -{ |
|
| 18 | +interface ConfigurableIO { |
|
| 20 | 19 | /** |
| 21 | 20 | * Configures the input and output instances based on the user arguments and |
| 22 | 21 | * options. This is executed before running the application. |
@@ -21,46 +21,46 @@ |
||
| 21 | 21 | |
| 22 | 22 | final class ApplicationRunner |
| 23 | 23 | { |
| 24 | - private SymfonyApplication $application; |
|
| 24 | + private SymfonyApplication $application; |
|
| 25 | 25 | |
| 26 | - public function __construct(Application $application) |
|
| 27 | - { |
|
| 28 | - $this->application = new SymfonyApplication($application); |
|
| 29 | - } |
|
| 26 | + public function __construct(Application $application) |
|
| 27 | + { |
|
| 28 | + $this->application = new SymfonyApplication($application); |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * Executes the given application command. |
|
| 33 | - * |
|
| 34 | - * @return int 0 if everything went fine, or an exit code |
|
| 35 | - * |
|
| 36 | - * @see ExitCode |
|
| 37 | - */ |
|
| 38 | - public static function runApplication( |
|
| 39 | - Application $application, |
|
| 40 | - ?InputInterface $input, |
|
| 41 | - ?OutputInterface $output |
|
| 42 | - ): int { |
|
| 43 | - return (new self($application))->run( |
|
| 44 | - new IO( |
|
| 45 | - $input ?? new ArgvInput(), |
|
| 46 | - $output ?? new ConsoleOutput(), |
|
| 47 | - ), |
|
| 48 | - ); |
|
| 49 | - } |
|
| 31 | + /** |
|
| 32 | + * Executes the given application command. |
|
| 33 | + * |
|
| 34 | + * @return int 0 if everything went fine, or an exit code |
|
| 35 | + * |
|
| 36 | + * @see ExitCode |
|
| 37 | + */ |
|
| 38 | + public static function runApplication( |
|
| 39 | + Application $application, |
|
| 40 | + ?InputInterface $input, |
|
| 41 | + ?OutputInterface $output |
|
| 42 | + ): int { |
|
| 43 | + return (new self($application))->run( |
|
| 44 | + new IO( |
|
| 45 | + $input ?? new ArgvInput(), |
|
| 46 | + $output ?? new ConsoleOutput(), |
|
| 47 | + ), |
|
| 48 | + ); |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * @see ApplicationRunner::runApplication() |
|
| 53 | - */ |
|
| 54 | - public function run(?IO $io = null): int |
|
| 55 | - { |
|
| 56 | - if (null === $io) { |
|
| 57 | - $input = null; |
|
| 58 | - $output = null; |
|
| 59 | - } else { |
|
| 60 | - $input = $io->getInput(); |
|
| 61 | - $output = $io->getOutput(); |
|
| 62 | - } |
|
| 51 | + /** |
|
| 52 | + * @see ApplicationRunner::runApplication() |
|
| 53 | + */ |
|
| 54 | + public function run(?IO $io = null): int |
|
| 55 | + { |
|
| 56 | + if (null === $io) { |
|
| 57 | + $input = null; |
|
| 58 | + $output = null; |
|
| 59 | + } else { |
|
| 60 | + $input = $io->getInput(); |
|
| 61 | + $output = $io->getOutput(); |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - return $this->application->run($input, $output); |
|
| 65 | - } |
|
| 64 | + return $this->application->run($input, $output); |
|
| 65 | + } |
|
| 66 | 66 | } |
@@ -19,8 +19,7 @@ |
||
| 19 | 19 | use Symfony\Component\Console\Output\ConsoleOutput; |
| 20 | 20 | use Symfony\Component\Console\Output\OutputInterface; |
| 21 | 21 | |
| 22 | -final class ApplicationRunner |
|
| 23 | -{ |
|
| 22 | +final class ApplicationRunner { |
|
| 24 | 23 | private SymfonyApplication $application; |
| 25 | 24 | |
| 26 | 25 | public function __construct(Application $application) |
@@ -22,20 +22,20 @@ |
||
| 22 | 22 | |
| 23 | 23 | final class FidryConsoleBundle extends Bundle |
| 24 | 24 | { |
| 25 | - public function getContainerExtension(): Extension |
|
| 26 | - { |
|
| 27 | - return new FidryConsoleExtension(); |
|
| 28 | - } |
|
| 25 | + public function getContainerExtension(): Extension |
|
| 26 | + { |
|
| 27 | + return new FidryConsoleExtension(); |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - public function build(ContainerBuilder $container): void |
|
| 31 | - { |
|
| 32 | - parent::build($container); |
|
| 30 | + public function build(ContainerBuilder $container): void |
|
| 31 | + { |
|
| 32 | + parent::build($container); |
|
| 33 | 33 | |
| 34 | - $container->addCompilerPass( |
|
| 35 | - new AddConsoleCommandPass(), |
|
| 36 | - PassConfig::TYPE_BEFORE_REMOVING, |
|
| 37 | - // Priority must be higher than Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass in FrameworkBundle |
|
| 38 | - 10, |
|
| 39 | - ); |
|
| 40 | - } |
|
| 34 | + $container->addCompilerPass( |
|
| 35 | + new AddConsoleCommandPass(), |
|
| 36 | + PassConfig::TYPE_BEFORE_REMOVING, |
|
| 37 | + // Priority must be higher than Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass in FrameworkBundle |
|
| 38 | + 10, |
|
| 39 | + ); |
|
| 40 | + } |
|
| 41 | 41 | } |
@@ -20,8 +20,7 @@ |
||
| 20 | 20 | use Symfony\Component\HttpKernel\Bundle\Bundle; |
| 21 | 21 | use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
| 22 | 22 | |
| 23 | -final class FidryConsoleBundle extends Bundle |
|
| 24 | -{ |
|
| 23 | +final class FidryConsoleBundle extends Bundle { |
|
| 25 | 24 | public function getContainerExtension(): Extension |
| 26 | 25 | { |
| 27 | 26 | return new FidryConsoleExtension(); |
@@ -15,11 +15,11 @@ |
||
| 15 | 15 | |
| 16 | 16 | final class ExitCode |
| 17 | 17 | { |
| 18 | - // see https://tldp.org/LDP/abs/html/exitcodes.html |
|
| 19 | - public const SUCCESS = 0; |
|
| 20 | - public const FAILURE = 1; |
|
| 18 | + // see https://tldp.org/LDP/abs/html/exitcodes.html |
|
| 19 | + public const SUCCESS = 0; |
|
| 20 | + public const FAILURE = 1; |
|
| 21 | 21 | |
| 22 | - private function __construct() |
|
| 23 | - { |
|
| 24 | - } |
|
| 22 | + private function __construct() |
|
| 23 | + { |
|
| 24 | + } |
|
| 25 | 25 | } |
@@ -13,8 +13,7 @@ |
||
| 13 | 13 | |
| 14 | 14 | namespace Fidry\Console; |
| 15 | 15 | |
| 16 | -final class ExitCode |
|
| 17 | -{ |
|
| 16 | +final class ExitCode { |
|
| 18 | 17 | // see https://tldp.org/LDP/abs/html/exitcodes.html |
| 19 | 18 | public const SUCCESS = 0; |
| 20 | 19 | public const FAILURE = 1; |
@@ -24,20 +24,20 @@ |
||
| 24 | 24 | */ |
| 25 | 25 | final class DisplayNormalizer |
| 26 | 26 | { |
| 27 | - private function __construct() |
|
| 28 | - { |
|
| 29 | - } |
|
| 30 | - |
|
| 31 | - public static function removeTrailingSpaces(string $display): string |
|
| 32 | - { |
|
| 33 | - $display = str_replace(PHP_EOL, "\n", $display); |
|
| 34 | - $lines = explode("\n", $display); |
|
| 35 | - |
|
| 36 | - $lines = array_map( |
|
| 37 | - 'rtrim', |
|
| 38 | - $lines |
|
| 39 | - ); |
|
| 40 | - |
|
| 41 | - return implode("\n", $lines); |
|
| 42 | - } |
|
| 27 | + private function __construct() |
|
| 28 | + { |
|
| 29 | + } |
|
| 30 | + |
|
| 31 | + public static function removeTrailingSpaces(string $display): string |
|
| 32 | + { |
|
| 33 | + $display = str_replace(PHP_EOL, "\n", $display); |
|
| 34 | + $lines = explode("\n", $display); |
|
| 35 | + |
|
| 36 | + $lines = array_map( |
|
| 37 | + 'rtrim', |
|
| 38 | + $lines |
|
| 39 | + ); |
|
| 40 | + |
|
| 41 | + return implode("\n", $lines); |
|
| 42 | + } |
|
| 43 | 43 | } |
@@ -22,8 +22,7 @@ |
||
| 22 | 22 | /** |
| 23 | 23 | * Utility class which helps to compare command outputs. |
| 24 | 24 | */ |
| 25 | -final class DisplayNormalizer |
|
| 26 | -{ |
|
| 25 | +final class DisplayNormalizer { |
|
| 27 | 26 | private function __construct() |
| 28 | 27 | { |
| 29 | 28 | } |
@@ -17,13 +17,13 @@ |
||
| 17 | 17 | |
| 18 | 18 | interface InteractiveCommand extends Command |
| 19 | 19 | { |
| 20 | - /** |
|
| 21 | - * Its purpose is to check if some of the options/arguments are missing and |
|
| 22 | - * interactively ask the user for those values. This is the last place where |
|
| 23 | - * you can ask for missing options/arguments. After this command, missing |
|
| 24 | - * options/arguments will result in an error. |
|
| 25 | - * |
|
| 26 | - * Note that this method is ignored if the input is not interactive. |
|
| 27 | - */ |
|
| 28 | - public function interact(IO $io): void; |
|
| 20 | + /** |
|
| 21 | + * Its purpose is to check if some of the options/arguments are missing and |
|
| 22 | + * interactively ask the user for those values. This is the last place where |
|
| 23 | + * you can ask for missing options/arguments. After this command, missing |
|
| 24 | + * options/arguments will result in an error. |
|
| 25 | + * |
|
| 26 | + * Note that this method is ignored if the input is not interactive. |
|
| 27 | + */ |
|
| 28 | + public function interact(IO $io): void; |
|
| 29 | 29 | } |
@@ -15,8 +15,7 @@ |
||
| 15 | 15 | |
| 16 | 16 | use Fidry\Console\IO; |
| 17 | 17 | |
| 18 | -interface InteractiveCommand extends Command |
|
| 19 | -{ |
|
| 18 | +interface InteractiveCommand extends Command { |
|
| 20 | 19 | /** |
| 21 | 20 | * Its purpose is to check if some of the options/arguments are missing and |
| 22 | 21 | * interactively ask the user for those values. This is the last place where |