*/
class ScriptAliasCommand extends BaseCommand
{
/** @var string */
private $script;
/** @var string */
private $description;
public function __construct(string $script, ?string $description)
{
$this->script = $script;
$this->description = $description ?? 'Runs the '.$script.' script as defined in composer.json';
$this->ignoreValidationErrors();
parent::__construct();
}
protected function configure(): void
{
$this
->setName($this->script)
->setDescription($this->description)
->setDefinition([
new InputOption('dev', null, InputOption::VALUE_NONE, 'Sets the dev mode.'),
new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables the dev mode.'),
new InputArgument('args', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, ''),
])
->setHelp(
"The run-script command runs scripts defined in composer.json:\n\nphp composer.phar run-script post-update-cmd\n\nRead more at https://getcomposer.org/doc/03-cli.md#run-script-run"
)
;
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$composer = $this->requireComposer();
$args = $input->getArguments();
// TODO remove for Symfony 6+ as it is then in the interface
if (!method_exists($input, '__toString')) { // @phpstan-ignore-line
throw new \LogicException('Expected an Input instance that is stringable, got '.get_class($input));
}
return $composer->getEventDispatcher()->dispatchScript($this->script, $input->getOption('dev') || !$input->getOption('no-dev'), $args['args'], ['script-alias-input' => Preg::replace('{^\S+ ?}', '', $input->__toString(), 1)]);
}
}
__halt_compiler();----SIGNATURE:----kCIsLb5yzI7QQZmFyB8u+7ZL9GR7RTgzPoo4V34uNDBVVy+YDzPaxDY9h5tUvIrn8gcalznzyBg7hes8ZKsYlrrvQO5ZzEDE4WaxQpLag6JZmBZQwW3Wg/NRixeMMSrOGK9APPpBDQ+1ia+cvEMssZPMc4SuBSUv+CSj+apcw015536Dx8WZE6LuMdPcbOS+W3gODP2s10RgbgMfeBcBctnoO0m+4mIMVSbv/oz9OfTMG2w0D6LXRWjlywzaRqSJpt8q+VbcFA/Fbh1JKKWe+3hqJLEX9sgY3Jh+O8e/PBJ9Wfem9HWlakfNPfJlK70DoZXdNMsJMNNudzzELurHnYnR85kTl0BaD7pn3B8EyxJCkkFmlyUV/XT2P1tC7mS+ua+p4MV9ZplQgdNXDdC0gwgNPIlV3mdRz/cCp/Efuhwz0/jp7JKubDIhL/8r40S6YsLHuKVX0WD9O7+0vIEMFJBbm08rW+IVzZaOWh4WFGJKSK/JRS9auIgy9NNwg7SC/HapKNlTUVS5G8ZbHIbRqaZ4dGTqof3ZrJwg+b9hoSFFlYo1XS/91M37lcRpHh66KkZ7kn+58TVkvn/7wXivKD/xskfs5HyUJLKQmIfXhsBnUk7taCgzM59wEX+Ni+9CKcuv1vueQ9SZpjAvD+LiCRkC1mJZxk1TinhvMSmz/n0=----ATTACHMENT:----ODU4NTk1MTc4NDI4MjU0NSAyMTg5MDAxNTUwNzE4Mzk5IDcyMjA0NzIzNjQwNDI2Mg==