Delete ICommand

2.x
Julien Rosset 2 years ago
parent b223377a54
commit f56593b270

@ -49,13 +49,14 @@ trait AutoDiscoveryApplication {
/**
* Add discovered commands to application
*
* @return void
* @return $this
*/
public function addDiscoveredCommands (): void {
public function addAutoDiscoveredCommands (): self {
foreach ($this->getAutoDiscoverySpots() as $autoDiscoverySpot) {
foreach ($autoDiscoverySpot->getCommands() as $command) {
$this->add($command);
}
}
return $this;
}
}

@ -83,7 +83,7 @@ class AutoDiscoverySpot implements IAutoDiscoverySpot {
* @param string $directoryPath The directory path
* @param bool $processSubDirectories True if search in subdirectories too, else False
*
* @return (ICommand&Command)[] Spot's classes
* @return Command[] Spot's classes
*/
private static function getClassesOfDirectory (string $directoryPath, bool $processSubDirectories): array {
$classes = [];
@ -115,7 +115,6 @@ class AutoDiscoverySpot implements IAutoDiscoverySpot {
if ($class->isAbstract()
|| $class->isInterface()
|| $class->isTrait()
|| !$class->implementsInterface(ICommand::class)
|| !is_subclass_of($class->getName(), Command::class)
) {
continue;

@ -7,7 +7,7 @@ use Symfony\Component\Console\Command\Command;
/**
* A basic command
*/
class BaseCommand extends Command implements ICommand {
class BaseCommand extends Command {
/**
* Initialize the command
*

@ -11,7 +11,7 @@ interface IAutoDiscoverySpot {
/**
* Spot's commands
*
* @return (ICommand&Command)[] Spot's commands
* @return Command[] Spot's commands
*/
public function getCommands (): array;
}

@ -1,21 +0,0 @@
<?php
namespace jrosset\CliProgram;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Throwable;
/**
* Interface for all commands
*/
interface ICommand {
/**
* Runs the command.
*
* @return int The command exit code
*
* @throws Throwable If an error occurs
*/
public function run (InputInterface $input, OutputInterface $output): int;
}
Loading…
Cancel
Save