diff --git a/src/Laravel/Bridge/Command/FlasherCommand.php b/src/Laravel/Bridge/Command/FlasherCommand.php new file mode 100644 index 00000000..9c0a71e0 --- /dev/null +++ b/src/Laravel/Bridge/Command/FlasherCommand.php @@ -0,0 +1,28 @@ + + */ + +namespace Flasher\Laravel\Bridge\Command; + +use Flasher\Laravel\Support\Laravel; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; + +$class = Laravel::isVersion('11.0', '>=') + ? 'Flasher\Laravel\Bridge\Typed\Command\FlasherCommand' + : 'Flasher\Laravel\Bridge\Legacy\Command\FlasherCommand'; + +class_alias($class, 'Flasher\Laravel\Bridge\Command\FlasherCommand'); + +if (false) { /** @phpstan-ignore-line */ + abstract class FlasherCommand + { + /** + * @return int + */ + abstract protected function flasherExecute(InputInterface $input, OutputInterface $output); + } +} diff --git a/src/Laravel/Bridge/Legacy/Command/FlasherCommand.php b/src/Laravel/Bridge/Legacy/Command/FlasherCommand.php new file mode 100644 index 00000000..2e4868d7 --- /dev/null +++ b/src/Laravel/Bridge/Legacy/Command/FlasherCommand.php @@ -0,0 +1,25 @@ + + */ + +namespace Flasher\Laravel\Bridge\Legacy\Command; + +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; + +abstract class FlasherCommand extends Command +{ + protected function execute(InputInterface $input, OutputInterface $output) + { + return $this->flasherExecute($input, $output); + } + + /** + * @return int + */ + abstract protected function flasherExecute(InputInterface $input, OutputInterface $output); +} diff --git a/src/Laravel/Bridge/Typed/Command/FlasherCommand.php b/src/Laravel/Bridge/Typed/Command/FlasherCommand.php new file mode 100644 index 00000000..14b7be38 --- /dev/null +++ b/src/Laravel/Bridge/Typed/Command/FlasherCommand.php @@ -0,0 +1,25 @@ + + */ + +namespace Flasher\Laravel\Bridge\Typed\Command; + +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; + +abstract class FlasherCommand extends Command +{ + protected function execute(InputInterface $input, OutputInterface $output): int + { + return $this->flasherExecute($input, $output); + } + + /** + * @return int + */ + abstract protected function flasherExecute(InputInterface $input, OutputInterface $output); +} diff --git a/src/Laravel/Command/InstallCommand.php b/src/Laravel/Command/InstallCommand.php index ebe0213e..bcc50823 100644 --- a/src/Laravel/Command/InstallCommand.php +++ b/src/Laravel/Command/InstallCommand.php @@ -9,14 +9,14 @@ namespace Flasher\Laravel\Command; use Flasher\Laravel\Support\ServiceProvider as FlasherServiceProvider; use Flasher\Prime\Plugin\PluginInterface; +use Flasher\Symfony\Bridge\Command\FlasherCommand; use Illuminate\Filesystem\Filesystem; use Illuminate\Support\Facades\App; use Illuminate\Support\ServiceProvider; -use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -class InstallCommand extends Command +class InstallCommand extends FlasherCommand { /** * @return void @@ -32,7 +32,7 @@ class InstallCommand extends Command /** * @return int */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function flasherExecute(InputInterface $input, OutputInterface $output) { $output->writeln(''); $output->writeln('