diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-08-16 13:59:28 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-08-16 13:59:28 +0900 |
| commit | b4ab3df2ec85fbe477d7721344a8cd3630b437a1 (patch) | |
| tree | eb618cbbdfa46cf829031f9c427dc09ef7584831 /crates/shirabe-php-rpc/php/guards/Composer/Installer.php | |
| parent | baf9aff3134ac5a10260d3be421a2c17a0180d64 (diff) | |
| download | php-shirabe-b4ab3df2ec85fbe477d7721344a8cd3630b437a1.tar.gz php-shirabe-b4ab3df2ec85fbe477d7721344a8cd3630b437a1.tar.zst php-shirabe-b4ab3df2ec85fbe477d7721344a8cd3630b437a1.zip | |
feat(plugin): guard Rust-owned classes the worker has no proxy for
The worker's autoloader fell through to the real Composer source for every
Rust-owned FQCN without a proxy stub, so plugin code doing `new Filesystem()`
or subclassing `LibraryInstaller` silently ran on a second instance the Rust
side never sees. An unimplemented part of the plugin API has to fail with an
explicit error naming it, not quietly work on a disconnected copy.
The stub generator now emits a guard class for each of those FQCNs: the real
declaration, hierarchy and constants, with every constructor and method
raising an explicit error. References satisfied by the declaration alone
(`instanceof`, `X::class`, `Link::TYPE_REQUIRE`) keep working. Two FQCNs stay
resolvable to the real class, each listed with the worker-side mechanism that
makes a natively constructed instance correct.
The error had nowhere to go: `Installer::run` dropped the `Result` of both
`dispatch_script` calls, so an exception from a listener ended in exit 0.
Both propagate now, the way the exception does upstream.
Three real-plugin E2E comparisons stop at a guard and are ignored, each
naming the class it needs.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe-php-rpc/php/guards/Composer/Installer.php')
| -rw-r--r-- | crates/shirabe-php-rpc/php/guards/Composer/Installer.php | 253 |
1 files changed, 253 insertions, 0 deletions
diff --git a/crates/shirabe-php-rpc/php/guards/Composer/Installer.php b/crates/shirabe-php-rpc/php/guards/Composer/Installer.php new file mode 100644 index 00000000..7197f97c --- /dev/null +++ b/crates/shirabe-php-rpc/php/guards/Composer/Installer.php @@ -0,0 +1,253 @@ +<?php + +// Generated by scripts/plugin-stub-generator; do not edit by hand. +// Guard for Composer\Installer. +// The Rust side owns this class and the worker has no proxy for it, so this +// declaration shadows the real one: the constants and the hierarchy stay, while +// constructing it or calling anything on it raises an explicit error. + +namespace Composer; + +use Composer\Advisory\AuditConfig; +use Composer\Autoload\AutoloadGenerator; +use Composer\DependencyResolver\LockTransaction; +use Composer\DependencyResolver\PolicyInterface; +use Composer\Downloader\DownloadManager; +use Composer\EventDispatcher\EventDispatcher; +use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterInterface; +use Composer\Installer\InstallationManager; +use Composer\Installer\SuggestedPackagesReporter; +use Composer\IO\IOInterface; +use Composer\Package\Locker; +use Composer\Package\RootPackageInterface; +use Composer\Repository\InstalledRepositoryInterface; +use Composer\Repository\PlatformRepository; +use Composer\Repository\RepositoryInterface; +use Composer\Repository\RepositoryManager; +use Composer\Repository\LockArrayRepository; + +class Installer +{ + public const ERROR_NONE = 0; // no error/success state + public const ERROR_GENERIC_FAILURE = 1; + public const ERROR_NO_LOCK_FILE_FOR_PARTIAL_UPDATE = 3; + public const ERROR_LOCK_FILE_INVALID = 4; + public const ERROR_DEPENDENCY_RESOLUTION_FAILED = 2; + public const ERROR_AUDIT_FAILED = 5; + public const ERROR_TRANSPORT_EXCEPTION = 100; + + public function __construct(IOInterface $io, Config $config, RootPackageInterface $package, DownloadManager $downloadManager, RepositoryManager $repositoryManager, Locker $locker, InstallationManager $installationManager, EventDispatcher $eventDispatcher, AutoloadGenerator $autoloadGenerator) + { + \ShirabeUnsupportedClass::fail(self::class, '__construct'); + } + + public function run(): int + { + \ShirabeUnsupportedClass::fail(self::class, 'run'); + } + + protected function doUpdate(InstalledRepositoryInterface $localRepo, bool $doInstall): int + { + \ShirabeUnsupportedClass::fail(self::class, 'doUpdate'); + } + + protected function extractDevPackages(LockTransaction $lockTransaction, PlatformRepository $platformRepo, array $aliases, PolicyInterface $policy, ?LockArrayRepository $lockedRepository = null): int + { + \ShirabeUnsupportedClass::fail(self::class, 'extractDevPackages'); + } + + protected function doInstall(InstalledRepositoryInterface $localRepo, bool $alreadySolved = false): int + { + \ShirabeUnsupportedClass::fail(self::class, 'doInstall'); + } + + protected function createPlatformRepo(bool $forUpdate): PlatformRepository + { + \ShirabeUnsupportedClass::fail(self::class, 'createPlatformRepo'); + } + + public static function create(IOInterface $io, Composer $composer): self + { + \ShirabeUnsupportedClass::fail(self::class, 'create'); + } + + public function setIgnoredTypes(array $types): self + { + \ShirabeUnsupportedClass::fail(self::class, 'setIgnoredTypes'); + } + + public function setAllowedTypes(?array $types): self + { + \ShirabeUnsupportedClass::fail(self::class, 'setAllowedTypes'); + } + + public function setAdditionalFixedRepository(RepositoryInterface $additionalFixedRepository): self + { + \ShirabeUnsupportedClass::fail(self::class, 'setAdditionalFixedRepository'); + } + + public function setTemporaryConstraints(array $constraints): self + { + \ShirabeUnsupportedClass::fail(self::class, 'setTemporaryConstraints'); + } + + public function setDryRun(bool $dryRun = true): self + { + \ShirabeUnsupportedClass::fail(self::class, 'setDryRun'); + } + + public function isDryRun(): bool + { + \ShirabeUnsupportedClass::fail(self::class, 'isDryRun'); + } + + public function setDownloadOnly(bool $downloadOnly = true): self + { + \ShirabeUnsupportedClass::fail(self::class, 'setDownloadOnly'); + } + + public function setPreferSource(bool $preferSource = true): self + { + \ShirabeUnsupportedClass::fail(self::class, 'setPreferSource'); + } + + public function setPreferDist(bool $preferDist = true): self + { + \ShirabeUnsupportedClass::fail(self::class, 'setPreferDist'); + } + + public function setOptimizeAutoloader(bool $optimizeAutoloader): self + { + \ShirabeUnsupportedClass::fail(self::class, 'setOptimizeAutoloader'); + } + + public function setClassMapAuthoritative(bool $classMapAuthoritative): self + { + \ShirabeUnsupportedClass::fail(self::class, 'setClassMapAuthoritative'); + } + + public function setApcuAutoloader(bool $apcuAutoloader, ?string $apcuAutoloaderPrefix = null): self + { + \ShirabeUnsupportedClass::fail(self::class, 'setApcuAutoloader'); + } + + public function setUpdate(bool $update): self + { + \ShirabeUnsupportedClass::fail(self::class, 'setUpdate'); + } + + public function setInstall(bool $install): self + { + \ShirabeUnsupportedClass::fail(self::class, 'setInstall'); + } + + public function setDevMode(bool $devMode = true): self + { + \ShirabeUnsupportedClass::fail(self::class, 'setDevMode'); + } + + public function setDumpAutoloader(bool $dumpAutoloader = true): self + { + \ShirabeUnsupportedClass::fail(self::class, 'setDumpAutoloader'); + } + + public function setRunScripts(bool $runScripts = true): self + { + \ShirabeUnsupportedClass::fail(self::class, 'setRunScripts'); + } + + public function setConfig(Config $config): self + { + \ShirabeUnsupportedClass::fail(self::class, 'setConfig'); + } + + public function setVerbose(bool $verbose = true): self + { + \ShirabeUnsupportedClass::fail(self::class, 'setVerbose'); + } + + public function isVerbose(): bool + { + \ShirabeUnsupportedClass::fail(self::class, 'isVerbose'); + } + + public function setIgnorePlatformRequirements($ignorePlatformReqs): self + { + \ShirabeUnsupportedClass::fail(self::class, 'setIgnorePlatformRequirements'); + } + + public function setPlatformRequirementFilter(PlatformRequirementFilterInterface $platformRequirementFilter): self + { + \ShirabeUnsupportedClass::fail(self::class, 'setPlatformRequirementFilter'); + } + + public function setUpdateMirrors(bool $updateMirrors): self + { + \ShirabeUnsupportedClass::fail(self::class, 'setUpdateMirrors'); + } + + public function setUpdateAllowList(array $packages): self + { + \ShirabeUnsupportedClass::fail(self::class, 'setUpdateAllowList'); + } + + public function setUpdateAllowTransitiveDependencies(int $updateAllowTransitiveDependencies): self + { + \ShirabeUnsupportedClass::fail(self::class, 'setUpdateAllowTransitiveDependencies'); + } + + public function setPreferStable(bool $preferStable = true): self + { + \ShirabeUnsupportedClass::fail(self::class, 'setPreferStable'); + } + + public function setPreferLowest(bool $preferLowest = true): self + { + \ShirabeUnsupportedClass::fail(self::class, 'setPreferLowest'); + } + + public function setMinimalUpdate(bool $minimalUpdate = true): self + { + \ShirabeUnsupportedClass::fail(self::class, 'setMinimalUpdate'); + } + + public function setWriteLock(bool $writeLock = true): self + { + \ShirabeUnsupportedClass::fail(self::class, 'setWriteLock'); + } + + public function setExecuteOperations(bool $executeOperations = true): self + { + \ShirabeUnsupportedClass::fail(self::class, 'setExecuteOperations'); + } + + public function setAudit(bool $audit): self + { + \ShirabeUnsupportedClass::fail(self::class, 'setAudit'); + } + + public function setErrorOnAudit(bool $errorOnAudit): self + { + \ShirabeUnsupportedClass::fail(self::class, 'setErrorOnAudit'); + } + + public function setAuditFormat(string $auditFormat): self + { + \ShirabeUnsupportedClass::fail(self::class, 'setAuditFormat'); + } + + public function setAuditConfig(AuditConfig $auditConfig): self + { + \ShirabeUnsupportedClass::fail(self::class, 'setAuditConfig'); + } + + public function disablePlugins(): self + { + \ShirabeUnsupportedClass::fail(self::class, 'disablePlugins'); + } + + public function setSuggestedPackagesReporter(SuggestedPackagesReporter $suggestedPackagesReporter): self + { + \ShirabeUnsupportedClass::fail(self::class, 'setSuggestedPackagesReporter'); + } +} |
