diff options
| author | Greg Roach <greg@subaqua.co.uk> | 2026-02-11 09:18:46 +0000 |
|---|---|---|
| committer | Greg Roach <greg@subaqua.co.uk> | 2026-02-11 09:20:42 +0000 |
| commit | 568b28c165fb3d1e6102448e10e662b8691a8090 (patch) | |
| tree | 1d4ad644074583227a68a9042a85d6fc13bdcd3d | |
| parent | 34c8190846b2eeed79307c76a6fd30a7eb679d54 (diff) | |
| download | webtrees-568b28c165fb3d1e6102448e10e662b8691a8090.tar.gz webtrees-568b28c165fb3d1e6102448e10e662b8691a8090.tar.bz2 webtrees-568b28c165fb3d1e6102448e10e662b8691a8090.zip | |
Ensure CLI commands only run from the CLI
| -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); |
