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/Autoload/AutoloadGenerator.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/Autoload/AutoloadGenerator.php')
| -rw-r--r-- | crates/shirabe-php-rpc/php/guards/Composer/Autoload/AutoloadGenerator.php | 143 |
1 files changed, 143 insertions, 0 deletions
diff --git a/crates/shirabe-php-rpc/php/guards/Composer/Autoload/AutoloadGenerator.php b/crates/shirabe-php-rpc/php/guards/Composer/Autoload/AutoloadGenerator.php new file mode 100644 index 00000000..92b6edad --- /dev/null +++ b/crates/shirabe-php-rpc/php/guards/Composer/Autoload/AutoloadGenerator.php @@ -0,0 +1,143 @@ +<?php + +// Generated by scripts/plugin-stub-generator; do not edit by hand. +// Guard for Composer\Autoload\AutoloadGenerator. +// 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\Autoload; + +use Composer\Config; +use Composer\EventDispatcher\EventDispatcher; +use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterInterface; +use Composer\Installer\InstallationManager; +use Composer\IO\IOInterface; +use Composer\Package\PackageInterface; +use Composer\Package\RootPackageInterface; +use Composer\Repository\InstalledRepositoryInterface; +use Composer\Util\Filesystem; +use Composer\Package\Locker; + +class AutoloadGenerator +{ + public function __construct(EventDispatcher $eventDispatcher, ?IOInterface $io = null) + { + \ShirabeUnsupportedClass::fail(self::class, '__construct'); + } + + public function setDevMode(bool $devMode = true) + { + \ShirabeUnsupportedClass::fail(self::class, 'setDevMode'); + } + + public function setClassMapAuthoritative(bool $classMapAuthoritative) + { + \ShirabeUnsupportedClass::fail(self::class, 'setClassMapAuthoritative'); + } + + public function setApcu(bool $apcu, ?string $apcuPrefix = null) + { + \ShirabeUnsupportedClass::fail(self::class, 'setApcu'); + } + + public function setRunScripts(bool $runScripts = true) + { + \ShirabeUnsupportedClass::fail(self::class, 'setRunScripts'); + } + + public function setDryRun(bool $dryRun = true): void + { + \ShirabeUnsupportedClass::fail(self::class, 'setDryRun'); + } + + public function setIgnorePlatformRequirements($ignorePlatformReqs) + { + \ShirabeUnsupportedClass::fail(self::class, 'setIgnorePlatformRequirements'); + } + + public function setPlatformRequirementFilter(PlatformRequirementFilterInterface $platformRequirementFilter) + { + \ShirabeUnsupportedClass::fail(self::class, 'setPlatformRequirementFilter'); + } + + public function dump(Config $config, InstalledRepositoryInterface $localRepo, RootPackageInterface $rootPackage, InstallationManager $installationManager, string $targetDir, bool $scanPsrPackages = false, ?string $suffix = null, ?Locker $locker = null, bool $strictAmbiguous = false) + { + \ShirabeUnsupportedClass::fail(self::class, 'dump'); + } + + public function buildPackageMap(InstallationManager $installationManager, PackageInterface $rootPackage, array $packages) + { + \ShirabeUnsupportedClass::fail(self::class, 'buildPackageMap'); + } + + protected function validatePackage(PackageInterface $package) + { + \ShirabeUnsupportedClass::fail(self::class, 'validatePackage'); + } + + public function parseAutoloads(array $packageMap, PackageInterface $rootPackage, $filteredDevPackages = false) + { + \ShirabeUnsupportedClass::fail(self::class, 'parseAutoloads'); + } + + public function createLoader(array $autoloads, ?string $vendorDir = null) + { + \ShirabeUnsupportedClass::fail(self::class, 'createLoader'); + } + + protected function getIncludePathsFile(array $packageMap, Filesystem $filesystem, string $basePath, string $vendorPath, string $vendorPathCode, string $appBaseDirCode) + { + \ShirabeUnsupportedClass::fail(self::class, 'getIncludePathsFile'); + } + + protected function getIncludeFilesFile(array $files, Filesystem $filesystem, string $basePath, string $vendorPath, string $vendorPathCode, string $appBaseDirCode) + { + \ShirabeUnsupportedClass::fail(self::class, 'getIncludeFilesFile'); + } + + protected function getPathCode(Filesystem $filesystem, string $basePath, string $vendorPath, string $path) + { + \ShirabeUnsupportedClass::fail(self::class, 'getPathCode'); + } + + protected function getPlatformCheck(array $packageMap, $checkPlatform, array $devPackageNames) + { + \ShirabeUnsupportedClass::fail(self::class, 'getPlatformCheck'); + } + + protected function getAutoloadFile(string $vendorPathToTargetDirCode, string $suffix) + { + \ShirabeUnsupportedClass::fail(self::class, 'getAutoloadFile'); + } + + protected function getAutoloadRealFile(bool $useClassMap, bool $useIncludePath, ?string $targetDirLoader, bool $useIncludeFiles, string $vendorPathCode, string $appBaseDirCode, string $suffix, bool $useGlobalIncludePath, string $prependAutoloader, bool $checkPlatform) + { + \ShirabeUnsupportedClass::fail(self::class, 'getAutoloadRealFile'); + } + + protected function getStaticFile(string $suffix, string $targetDir, string $vendorPath, string $basePath) + { + \ShirabeUnsupportedClass::fail(self::class, 'getStaticFile'); + } + + protected function parseAutoloadsType(array $packageMap, string $type, RootPackageInterface $rootPackage) + { + \ShirabeUnsupportedClass::fail(self::class, 'parseAutoloadsType'); + } + + protected function getFileIdentifier(PackageInterface $package, string $path) + { + \ShirabeUnsupportedClass::fail(self::class, 'getFileIdentifier'); + } + + protected function filterPackageMap(array $packageMap, RootPackageInterface $rootPackage) + { + \ShirabeUnsupportedClass::fail(self::class, 'filterPackageMap'); + } + + protected function sortPackageMap(array $packageMap) + { + \ShirabeUnsupportedClass::fail(self::class, 'sortPackageMap'); + } +} |
