diff options
| -rw-r--r-- | app/Cli/Commands/AbstractCommand.php | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/app/Cli/Commands/AbstractCommand.php b/app/Cli/Commands/AbstractCommand.php index 7e5b301b85..c175fb05fa 100644 --- a/app/Cli/Commands/AbstractCommand.php +++ b/app/Cli/Commands/AbstractCommand.php @@ -20,6 +20,7 @@ declare(strict_types=1); namespace Fisharebest\Webtrees\Cli\Commands; use InvalidArgumentException; +use LogicException; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; @@ -28,6 +29,15 @@ use function is_string; abstract class AbstractCommand extends Command { + public function __construct() + { + if (PHP_SAPI !== 'cli') { + throw new LogicException('Commands can only run from the command line.'); + } + + parent::__construct(); + } + protected function boolOption(InputInterface $input, string $name): bool { $value = $input->getOption(name: $name); |
