Dutchento / m2-vatfallback

Vatfallback module provides an extra API based validation and a fallback offline regex validation for the unstable VIES database used by Magento
https://www.dutchento.org
MIT License
37 stars 17 forks source link

execute()" must be of the type int, "null" returned #48

Closed kimb0na closed 4 weeks ago

kimb0na commented 4 weeks ago

Hi I've just installed the module and tried command line validation. (ver.2.4.7)

root@deploy:/app# bin/magento vat:validate BE 0402206045
Success is: 1, with service RegExp

There is an error in /app/vendor/symfony/console/Command/Command.php at line: 329
Return value of "Dutchento\Vatfallback\Console\Command\Validate\Interceptor::execute()" must be of the type int, "null" returned.#0 /app/vendor/magento/framework/Interception/Interceptor.php(58): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
...

and possible fix can be:

diff --git a/vendor/dutchento/m2-vatfallback/Console/Command/Validate.php b/vendor/dutchento/m2-vatfallback/Console/Command/Validate.php
index 3e1f4ce6..dff958c1 100644
--- a/vendor/dutchento/m2-vatfallback/Console/Command/Validate.php
+++ b/vendor/dutchento/m2-vatfallback/Console/Command/Validate.php
@@ -11,6 +11,7 @@ namespace Dutchento\Vatfallback\Console\Command;

 use Dutchento\Vatfallback\Service\Exceptions\NoValidationException;
 use Dutchento\Vatfallback\Service\ValidateVatInterface;
+use Magento\Framework\Console\Cli;
 use Symfony\Component\Console\Command\Command;
 use Symfony\Component\Console\Input\InputArgument;
 use Symfony\Component\Console\Input\InputInterface;
@@ -52,11 +53,15 @@ class Validate extends Command

             if ($result['result']) {
                 $output->writeln("Success is: {$result['result']}, with service {$result['service']}");
+                return Cli::RETURN_SUCCESS;
             } else {
                 $output->writeln("Invalid VAT number, with service {$result['service']}");
+                return Cli::RETURN_FAILURE;
             }
         } catch (NoValidationException $exception) {
             $output->writeln("No validation took place");
+
+            return Cli::RETURN_FAILURE;
         }
     }

please review, thanks!

peterjaap commented 4 weeks ago

Fix is correct, could you make a PR?

kimb0na commented 4 weeks ago

sure I will

peterjaap commented 4 weeks ago

Fixed in 2.1.1