From daf345746e0de73dd14b966b276bafb2359f784d Mon Sep 17 00:00:00 2001 From: Sleon4 Date: Mon, 18 Nov 2024 17:27:10 -0500 Subject: [PATCH] chore: the body of generated classes (Controllers) is validated --- src/LionBundle/Commands/Lion/DB/CrudCommand.php | 11 +++++++++-- .../Commands/Lion/New/ControllerCommand.php | 10 +++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/LionBundle/Commands/Lion/DB/CrudCommand.php b/src/LionBundle/Commands/Lion/DB/CrudCommand.php index 09c167dd..aedbb5d7 100644 --- a/src/LionBundle/Commands/Lion/DB/CrudCommand.php +++ b/src/LionBundle/Commands/Lion/DB/CrudCommand.php @@ -12,6 +12,8 @@ use Lion\Command\Command; use Lion\Database\Connection; use Lion\Database\Driver; +use LogicException; +use Symfony\Component\Console\Exception\ExceptionInterface; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -113,9 +115,10 @@ protected function configure(): void * @param OutputInterface $output [OutputInterface is the interface * implemented by all Output classes] * - * @return int [0 if everything went fine, or an exit code] + * @return int * - * @throws LogicException [When this abstract method is not implemented] + * @throws LogicException|ExceptionInterface [When this abstract method is + * not implemented] */ protected function execute(InputInterface $input, OutputInterface $output): int { @@ -171,6 +174,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int * implemented by all Output classes] * * @return void + * + * @throws ExceptionInterface */ private function addDBRules(string $entity, OutputInterface $output): void { @@ -197,6 +202,8 @@ private function addDBRules(string $entity, OutputInterface $output): void * implemented by all Output classes] * * @return void + * + * @throws ExceptionInterface */ private function addControllerAndModel( string $driver, diff --git a/src/LionBundle/Commands/Lion/New/ControllerCommand.php b/src/LionBundle/Commands/Lion/New/ControllerCommand.php index 56c786f1..be85eb36 100644 --- a/src/LionBundle/Commands/Lion/New/ControllerCommand.php +++ b/src/LionBundle/Commands/Lion/New/ControllerCommand.php @@ -10,6 +10,8 @@ use Lion\Command\Command; use Lion\Files\Store; use Lion\Helpers\Str; +use LogicException; +use Symfony\Component\Console\Exception\ExceptionInterface; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -110,9 +112,10 @@ protected function configure(): void * @param OutputInterface $output [OutputInterface is the interface * implemented by all Output classes] * - * @return int 0 if everything went fine, or an exit code + * @return int * - * @throws LogicException When this abstract method is not implemented + * @throws LogicException [When this abstract method is not implemented] + * @throws ExceptionInterface */ protected function execute(InputInterface $input, OutputInterface $output): int { @@ -165,12 +168,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int ); if ('none' != $model) { - $factoryController->add("\nuse {$dataModel->namespace}\\{$dataModel->class};\n"); + $factoryController->add("\nuse {$dataModel->namespace}\\{$dataModel->class};"); } $factoryController ->add( <<