aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/tests/plugin/fixtures/e2e-script-command/src/MismatchedNameCommand.php
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-08-10 23:47:33 +0900
committernsfisis <nsfisis@gmail.com>2026-08-10 23:47:33 +0900
commitb65e338d4cf06afb8237512e49a51e354277196d (patch)
tree5099c6bd950ff59acd5be15ff224b02d05563834 /crates/shirabe/tests/plugin/fixtures/e2e-script-command/src/MismatchedNameCommand.php
parent3f80f3c725245c769f05b6d3317f086e226fae50 (diff)
downloadphp-shirabe-b65e338d4cf06afb8237512e49a51e354277196d.tar.gz
php-shirabe-b65e338d4cf06afb8237512e49a51e354277196d.tar.zst
php-shirabe-b65e338d4cf06afb8237512e49a51e354277196d.zip
feat(console): import scripts Command classes as application commands
`Application::do_run` registers a `composer.json` script whose value names a `Symfony\Component\Console\Command\Command` subclass as a live command. The class checks and `new $dummy($script)` need a real PHP runtime, so they run in the worker: the command object lives there and this side keeps a metadata mirror for `list`/`help`, forwarding a run to the worker-side console application it is added to. The name and description fixups are applied to the worker-side object, so both sides carry the same values. Loading the Composer PHP runtime into the worker is gated on the Rust-side `ClassLoader`s resolving the class to a file, keeping that load out of every run whose scripts are plain shell commands. The worker-side console application handoff now accepts commands registered after it was published, since the scripts scan runs after plugin commands are collected. Whether it was published is tracked per application: the handoff is process-wide, so a second application must replace it rather than extend it. `shirabe_php_shim::is_subclass_of` has no callers left.
Diffstat (limited to 'crates/shirabe/tests/plugin/fixtures/e2e-script-command/src/MismatchedNameCommand.php')
-rw-r--r--crates/shirabe/tests/plugin/fixtures/e2e-script-command/src/MismatchedNameCommand.php23
1 files changed, 23 insertions, 0 deletions
diff --git a/crates/shirabe/tests/plugin/fixtures/e2e-script-command/src/MismatchedNameCommand.php b/crates/shirabe/tests/plugin/fixtures/e2e-script-command/src/MismatchedNameCommand.php
new file mode 100644
index 00000000..f3f6b05f
--- /dev/null
+++ b/crates/shirabe/tests/plugin/fixtures/e2e-script-command/src/MismatchedNameCommand.php
@@ -0,0 +1,23 @@
+<?php
+
+namespace ShirabeTest\ScriptCommand;
+
+use Symfony\Component\Console\Command\Command;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+
+class MismatchedNameCommand extends Command
+{
+ protected function configure(): void
+ {
+ $this->setName('not-the-script-name');
+ }
+
+ protected function execute(InputInterface $input, OutputInterface $output): int
+ {
+ $output->writeln('renamed: name=' . $this->getName());
+ $output->writeln('renamed: description=' . $this->getDescription());
+
+ return 0;
+ }
+}