diff options
Diffstat (limited to 'crates/shirabe-php-rpc/php')
| -rw-r--r-- | crates/shirabe-php-rpc/php/guards/Composer/Util/Filesystem.php | 167 | ||||
| -rw-r--r-- | crates/shirabe-php-rpc/php/stubs/Composer/Util/Filesystem.php | 243 |
2 files changed, 243 insertions, 167 deletions
diff --git a/crates/shirabe-php-rpc/php/guards/Composer/Util/Filesystem.php b/crates/shirabe-php-rpc/php/guards/Composer/Util/Filesystem.php deleted file mode 100644 index 6d8dbb24..00000000 --- a/crates/shirabe-php-rpc/php/guards/Composer/Util/Filesystem.php +++ /dev/null @@ -1,167 +0,0 @@ -<?php - -// Generated by scripts/plugin-stub-generator; do not edit by hand. -// Guard for Composer\Util\Filesystem. -// 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\Util; - -class Filesystem -{ - public function __construct(?ProcessExecutor $executor = null) - { - \ShirabeUnsupportedClass::fail(self::class, '__construct'); - } - - public function remove(string $file) - { - \ShirabeUnsupportedClass::fail(self::class, 'remove'); - } - - public function isDirEmpty(string $dir) - { - \ShirabeUnsupportedClass::fail(self::class, 'isDirEmpty'); - } - - public function emptyDirectory(string $dir, bool $ensureDirectoryExists = true) - { - \ShirabeUnsupportedClass::fail(self::class, 'emptyDirectory'); - } - - public function removeDirectory(string $directory) - { - \ShirabeUnsupportedClass::fail(self::class, 'removeDirectory'); - } - - public function removeDirectoryAsync(string $directory) - { - \ShirabeUnsupportedClass::fail(self::class, 'removeDirectoryAsync'); - } - - public function removeDirectoryPhp(string $directory) - { - \ShirabeUnsupportedClass::fail(self::class, 'removeDirectoryPhp'); - } - - public function ensureDirectoryExists(string $directory) - { - \ShirabeUnsupportedClass::fail(self::class, 'ensureDirectoryExists'); - } - - public function unlink(string $path) - { - \ShirabeUnsupportedClass::fail(self::class, 'unlink'); - } - - public function rmdir(string $path) - { - \ShirabeUnsupportedClass::fail(self::class, 'rmdir'); - } - - public function copyThenRemove(string $source, string $target) - { - \ShirabeUnsupportedClass::fail(self::class, 'copyThenRemove'); - } - - public function copy(string $source, string $target) - { - \ShirabeUnsupportedClass::fail(self::class, 'copy'); - } - - public function rename(string $source, string $target) - { - \ShirabeUnsupportedClass::fail(self::class, 'rename'); - } - - public function findShortestPath(string $from, string $to, bool $directories = false, bool $preferRelative = false) - { - \ShirabeUnsupportedClass::fail(self::class, 'findShortestPath'); - } - - public function findShortestPathCode(string $from, string $to, bool $directories = false, bool $staticCode = false, bool $preferRelative = false) - { - \ShirabeUnsupportedClass::fail(self::class, 'findShortestPathCode'); - } - - public function isAbsolutePath(string $path) - { - \ShirabeUnsupportedClass::fail(self::class, 'isAbsolutePath'); - } - - public function size(string $path) - { - \ShirabeUnsupportedClass::fail(self::class, 'size'); - } - - public function normalizePath(string $path) - { - \ShirabeUnsupportedClass::fail(self::class, 'normalizePath'); - } - - public static function trimTrailingSlash(string $path) - { - \ShirabeUnsupportedClass::fail(self::class, 'trimTrailingSlash'); - } - - public static function isLocalPath(string $path) - { - \ShirabeUnsupportedClass::fail(self::class, 'isLocalPath'); - } - - public static function getPlatformPath(string $path) - { - \ShirabeUnsupportedClass::fail(self::class, 'getPlatformPath'); - } - - public static function isReadable(string $path) - { - \ShirabeUnsupportedClass::fail(self::class, 'isReadable'); - } - - protected function directorySize(string $directory) - { - \ShirabeUnsupportedClass::fail(self::class, 'directorySize'); - } - - protected function getProcess() - { - \ShirabeUnsupportedClass::fail(self::class, 'getProcess'); - } - - public function relativeSymlink(string $target, string $link) - { - \ShirabeUnsupportedClass::fail(self::class, 'relativeSymlink'); - } - - public function isSymlinkedDirectory(string $directory) - { - \ShirabeUnsupportedClass::fail(self::class, 'isSymlinkedDirectory'); - } - - public function junction(string $target, string $junction) - { - \ShirabeUnsupportedClass::fail(self::class, 'junction'); - } - - public function isJunction(string $junction) - { - \ShirabeUnsupportedClass::fail(self::class, 'isJunction'); - } - - public function removeJunction(string $junction) - { - \ShirabeUnsupportedClass::fail(self::class, 'removeJunction'); - } - - public function filePutContentsIfModified(string $path, string $content) - { - \ShirabeUnsupportedClass::fail(self::class, 'filePutContentsIfModified'); - } - - public function safeCopy(string $source, string $target): void - { - \ShirabeUnsupportedClass::fail(self::class, 'safeCopy'); - } -} diff --git a/crates/shirabe-php-rpc/php/stubs/Composer/Util/Filesystem.php b/crates/shirabe-php-rpc/php/stubs/Composer/Util/Filesystem.php new file mode 100644 index 00000000..e1532889 --- /dev/null +++ b/crates/shirabe-php-rpc/php/stubs/Composer/Util/Filesystem.php @@ -0,0 +1,243 @@ +<?php + +// Generated by scripts/plugin-stub-generator; do not edit by hand. +// Proxy stub for Composer\Util\Filesystem: the public surface forwards to the Rust-side entity over RPC. + +namespace Composer\Util; + +use Composer\Pcre\Preg; + +class Filesystem implements \ShirabeRustStub +{ + /** @var int */ + protected $__rhandle; + /** @var int */ + protected $__epoch; + + /** + * Binds a stub the registry built for an existing entity. Proxy instantiation bypasses + * the constructor, which belongs to plugin code building a new entity instead. + */ + public function __shirabeBind(int $rhandle, int $epoch): void + { + $this->__rhandle = $rhandle; + $this->__epoch = $epoch; + } + + public function __destruct() + { + \ShirabeRustObjectRegistry::release($this->__rhandle); + } + + public function __shirabeRustHandleDescriptor(): array + { + return [ + '__rhandle' => $this->__rhandle, + '__class' => static::class, + '__epoch' => $this->__epoch, + ]; + } + + public function __clone() + { + // PHP has already shallow-copied this stub, so both copies would point at one + // entity and release it twice. The Rust side clones the entity instead, applying + // whatever __clone semantics the real class defines, and this copy rebinds to the + // fresh handle. Entities without clone semantics answer with an explicit error. + [$this->__rhandle, $this->__epoch] = \ShirabeRpcRuntime::callRust($this->__rhandle, '__shirabeClone', []); + \ShirabeRustObjectRegistry::adopt($this->__rhandle, $this); + } + + public function __get($name) + { + return \ShirabeRpcRuntime::callRust($this->__rhandle, '__get', [$name]); + } + + public function __set($name, $value): void + { + \ShirabeRpcRuntime::callRust($this->__rhandle, '__set', [$name, $value]); + } + + public function __isset($name): bool + { + return \ShirabeRpcRuntime::callRust($this->__rhandle, '__isset', [$name]); + } + + public function __unset($name): void + { + \ShirabeRpcRuntime::callRust($this->__rhandle, '__unset', [$name]); + } + + public function __construct(?ProcessExecutor $executor = null) + { + [$this->__rhandle, $this->__epoch] = \ShirabeRpcRuntime::callRust(0, '__shirabeConstruct', [static::class, [$executor]]); + \ShirabeRustObjectRegistry::adopt($this->__rhandle, $this); + } + + public static function trimTrailingSlash(string $path) + { + if (!Preg::isMatch('{^[/\\\\]+$}', $path)) { + $path = rtrim($path, '/\\'); + } + + return $path; + } + + public static function isLocalPath(string $path) + { + // on windows, \\foo indicates network paths so we exclude those from local paths, however it is unsafe + // on linux as file:////foo (which would be a network path \\foo on windows) will resolve to /foo which could be a local path + if (Platform::isWindows()) { + return Preg::isMatch('{^(file://(?!//)|/(?!/)|/?[a-z]:[\\\\/]|\.\.[\\\\/]|[a-z0-9_.-]+[\\\\/])}i', $path); + } + + return Preg::isMatch('{^(file://|/|/?[a-z]:[\\\\/]|\.\.[\\\\/]|[a-z0-9_.-]+[\\\\/])}i', $path); + } + + public static function getPlatformPath(string $path) + { + if (Platform::isWindows()) { + $path = Preg::replace('{^(?:file:///([a-z]):?/)}i', 'file://$1:/', $path); + } + + return Preg::replace('{^file://}i', '', $path); + } + + public static function isReadable(string $path) + { + if (is_readable($path)) { + return true; + } + + if (is_file($path)) { + return false !== Silencer::call('file_get_contents', $path, false, null, 0, 1); + } + + if (is_dir($path)) { + return false !== Silencer::call('opendir', $path); + } + + // assume false otherwise + return false; + } + + public function remove(string $file) + { + return \ShirabeRpcRuntime::callRust($this->__rhandle, 'remove', [$file]); + } + + public function isDirEmpty(string $dir) + { + return \ShirabeRpcRuntime::callRust($this->__rhandle, 'isDirEmpty', [$dir]); + } + + public function emptyDirectory(string $dir, bool $ensureDirectoryExists = true) + { + return \ShirabeRpcRuntime::callRust($this->__rhandle, 'emptyDirectory', [$dir, $ensureDirectoryExists]); + } + + public function removeDirectory(string $directory) + { + return \ShirabeRpcRuntime::callRust($this->__rhandle, 'removeDirectory', [$directory]); + } + + public function removeDirectoryAsync(string $directory) + { + return \ShirabeRpcRuntime::callRust($this->__rhandle, 'removeDirectoryAsync', [$directory]); + } + + public function removeDirectoryPhp(string $directory) + { + return \ShirabeRpcRuntime::callRust($this->__rhandle, 'removeDirectoryPhp', [$directory]); + } + + public function ensureDirectoryExists(string $directory) + { + return \ShirabeRpcRuntime::callRust($this->__rhandle, 'ensureDirectoryExists', [$directory]); + } + + public function unlink(string $path) + { + return \ShirabeRpcRuntime::callRust($this->__rhandle, 'unlink', [$path]); + } + + public function rmdir(string $path) + { + return \ShirabeRpcRuntime::callRust($this->__rhandle, 'rmdir', [$path]); + } + + public function copyThenRemove(string $source, string $target) + { + return \ShirabeRpcRuntime::callRust($this->__rhandle, 'copyThenRemove', [$source, $target]); + } + + public function copy(string $source, string $target) + { + return \ShirabeRpcRuntime::callRust($this->__rhandle, 'copy', [$source, $target]); + } + + public function rename(string $source, string $target) + { + return \ShirabeRpcRuntime::callRust($this->__rhandle, 'rename', [$source, $target]); + } + + public function findShortestPath(string $from, string $to, bool $directories = false, bool $preferRelative = false) + { + return \ShirabeRpcRuntime::callRust($this->__rhandle, 'findShortestPath', [$from, $to, $directories, $preferRelative]); + } + + public function findShortestPathCode(string $from, string $to, bool $directories = false, bool $staticCode = false, bool $preferRelative = false) + { + return \ShirabeRpcRuntime::callRust($this->__rhandle, 'findShortestPathCode', [$from, $to, $directories, $staticCode, $preferRelative]); + } + + public function isAbsolutePath(string $path) + { + return \ShirabeRpcRuntime::callRust($this->__rhandle, 'isAbsolutePath', [$path]); + } + + public function size(string $path) + { + return \ShirabeRpcRuntime::callRust($this->__rhandle, 'size', [$path]); + } + + public function normalizePath(string $path) + { + return \ShirabeRpcRuntime::callRust($this->__rhandle, 'normalizePath', [$path]); + } + + public function relativeSymlink(string $target, string $link) + { + return \ShirabeRpcRuntime::callRust($this->__rhandle, 'relativeSymlink', [$target, $link]); + } + + public function isSymlinkedDirectory(string $directory) + { + return \ShirabeRpcRuntime::callRust($this->__rhandle, 'isSymlinkedDirectory', [$directory]); + } + + public function junction(string $target, string $junction) + { + return \ShirabeRpcRuntime::callRust($this->__rhandle, 'junction', [$target, $junction]); + } + + public function isJunction(string $junction) + { + return \ShirabeRpcRuntime::callRust($this->__rhandle, 'isJunction', [$junction]); + } + + public function removeJunction(string $junction) + { + return \ShirabeRpcRuntime::callRust($this->__rhandle, 'removeJunction', [$junction]); + } + + public function filePutContentsIfModified(string $path, string $content) + { + return \ShirabeRpcRuntime::callRust($this->__rhandle, 'filePutContentsIfModified', [$path, $content]); + } + + public function safeCopy(string $source, string $target): void + { + \ShirabeRpcRuntime::callRust($this->__rhandle, 'safeCopy', [$source, $target]); + } +} |
