aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe-php-shim/src/lib.rs
AgeCommit message (Collapse)Author
2026-06-20refactor: auto-fix clippy warningsnsfisis
2026-06-20feat(php-shim): implement count()nsfisis
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-20feat(command): implement --help outputnsfisis
2026-06-19test(command): add basic smoke testsnsfisis
2026-06-19feat(command): implement Symfony Commandnsfisis
2026-06-14feat(php-shim): implement more shim functionsnsfisis
2026-06-14feat(php-shim): implement random_int/random_bytes with fastrandnsfisis
PHP's random_int/random_bytes are cryptographically secure, but Composer does not rely on that property, so a non-cryptographic PRNG suffices. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-14refactor: auto-fix clippy warningsnsfisis
2026-06-14refactor(pcre): move preg_* free functions into php-shimnsfisis
The free preg_* functions, the CaptureKey type, and the PREG_* constants move from the pcre crate into shirabe-php-shim, where the rest of the PHP standard-library shims live. Colliding names take a 2 suffix (preg_match2, preg_split2, etc.) since the shim already exposes differently-shaped variants. Preg keeps its public API and delegates to the relocated functions; CaptureKey is re-exported from composer::pcre so consumers are unaffected. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-14feat(pcre): implement preg_* functionsnsfisis
Replace the todo!() stubs backing the Preg class and the standalone preg_* shim helpers with regex-crate implementations.
2026-06-14feat(php-shim): port some functions to Rustnsfisis
2026-06-13refactor(http): drop unworkable set_error_handler warning capturensfisis
PHP wraps fopen/file_get_contents/file_put_contents in set_error_handler to capture warning text into error_message. Rust reports I/O failures through return values rather than warnings, so this side channel cannot work; replace the calls with TODO(phase-c) notes and leave error_message empty until the I/O layer surfaces a reason. Also remove the now-unused set_error_handler_closure shim and make set_error_handler a no-op. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-13fix(console): flatten Application inheritance to restore overridesnsfisis
Composer\Console\Application embedded Symfony's Application as an `inner` field and delegated to it, so polymorphic calls inside the Symfony base (e.g. doRun -> $this->getLongVersion()) resolved to Symfony's own methods and never reached Composer's overrides. As a result `--version` bypassed Composer's getLongVersion()/doRun() entirely. Flatten the PHP inheritance chain into the single shirabe Application struct: take in the Symfony base methods (parent-calling overrides kept under a `base_` prefix) and drop the `inner` delegation. Replace the Symfony Application struct in shirabe-external-packages with an `Application` trait that the merged struct implements, so commands and descriptors can reference it without a reverse crate dependency. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-12refactor(php-shim): replace literal sprintf calls with format!nsfisis
Convert every sprintf() call with a compile-time literal format string to format!, implementing Display for PhpMixed (delegating to php_to_string) so PhpMixed values render with PHP string semantics through {}. Also merge the format!-wrapped and conditional-literal dynamic sites into single format! calls. Genuinely runtime format strings (table styles, configurable error messages, command synopsis, progress-bar modifiers, regex-built messages) still go through sprintf. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-12feat(php-shim): implement runtime functions to run --versionnsfisis
Replace todo!() stubs reached on the `composer --version` path so the command runs without panicking and exits cleanly: - introspection (function_exists, class_exists, extension_loaded, defined) via white-lists modeling a standard Linux PHP CLI - type casts: php_to_string/strval, php_truthy/boolval, substr, byte_at, explode, strtr_array - config/env: error_reporting, ini_get, date_default_timezone_*, server_get/server_contains_key, php_uname("s") - IO: turn PhpResource into an enum (Stdin/Stdout/Stderr/File) and implement fwrite/fflush/stream_isatty/php_fopen resource helpers - shutdown/exit: register_shutdown_function + run_shutdown_functions, exit, error_get_last - preg_match_all_offset_capture via the regex crate; the formatter pattern drops PCRE possessive quantifiers (original kept in a comment with a TODO) proc_open reports unavailable for now (TODO(phase-c)); terminal-size and tty detection fall back to defaults. sprintf calls on this path are rewritten with format!(). OutputFormatterStyleInterface gains clone_box to return shared styles. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-12feat(symfony-console): port Symfony Console and make the workspace compilensfisis
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-11feat(php-shim): implement realpath, putenv, and env/server mutatorsnsfisis
2026-06-11refactor(argv): use std::env::args instead of server_argv shimnsfisis
The server_argv() shim merely wrapped command-line arguments, so call std::env::args() directly at each use site and drop the unused shim.
2026-06-11feat(php-shim): implement trivial PHP-compatible stub functionsnsfisis
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-11chore(compiler): drop compiler.rsnsfisis
The Compiler.php is PHP-tooling only (bin/compile) with no Rust equivalent, so it is not ported. Remove the compiler module along with the symbols used solely by it. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-10feat(phase-c): resolve cross-module phase-b TODOsnsfisis
2026-06-10feat(phase-c): resolve exception-handling phase-b TODOsnsfisis
* Catch specific exception types instead of broad/placeholder handling. * Drop the shim Countable trait.
2026-06-09feat(datetime): resolve datetime TODOsnsfisis
Introduce shim functions and constants, replacing the ad-hoc chrono format strings and parse helpers used as phase-b placeholders. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-08feat(phase-c): resolve PHP-array-semantics phase-b TODOsnsfisis
Resolve category K (array_* functions, integer keys, nested mutation, sorting). Add shim variants (uasort over Vec<T>, uasort_map for IndexMap) and delegate to existing typed variants (strtr_array, array_merge_map, array_search_in_vec). Implement PHP array semantics directly where the shape is fixed: canonical integer-key coercion (is_php_integer_key, shared by config and FilesystemRepository::dumpToPhpCode), strict array_search via trait-object pointer identity, array_reverse/array_chunk preserve_keys loops, and the installed.php nested version mutations via auto-vivify helpers. Resolving the array_merge in UpdateCommand unmasked latent borrow bugs in execute's tail (Rc input/output moved by value); fixed with .clone() to match PHP reference sharing, and resolved the tightly-coupled Intervals constraint check. composerRequire reclassified to phase-c: it depends on the $GLOBALS superglobal and PHP's require include mechanism, neither portable. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-08feat(phase-c): resolve PhpMixed-conversion phase-b TODOsnsfisis
Implement the foundational PhpMixed conversion infrastructure (From<bool|i64|f64|String>, order-sensitive PartialEq matching PHP ===) and resolve the category-G phase-b TODOs that depend on it: - Fix VCS driver cache paths that discarded parsed JSON or diverged on null caches (svn/forgejo/gitlab/git-bitbucket/github). - Wire up real conversions previously stubbed or dropped: suggests platform config, audit ignore-severities, composer_repository search and ProviderInfo, class_loader prefix/classmap merges, locker lock diff comparison, advisory JSON serialization, SPDX license fields. - Make GenericRule take a typed ReasonData; populate RULE_ROOT_REQUIRE with the constraint and convert PhpMixed at the call sites.
2026-06-06feat(binary-installer): use file_get_contents with offset and lengthnsfisis
Add file_get_contents5 shim supporting use_include_path/context/offset/ length, and wire it into BinaryInstaller to read the first 500 bytes of the bin file, replacing the offset-less stub and its phase-b TODO. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-06feat(filesystem): model iterator failure to restore removal retrynsfisis
RecursiveDirectoryIterator construction can throw UnexpectedValueException; the shim now returns a Result so remove_directory_php can re-create the iterator once after clearstatcache()/usleep, mirroring Composer's retry for the spurious failures in composer/composer#4009. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-06fix(json-loader): pass decoded config to loader instead of empty mapnsfisis
The Phase B stub discarded the decoded PhpMixed and handed an empty IndexMap to LoaderInterface::load, so nothing was actually loaded. Unbox PhpMixed::Array into the map; mirror PHP's array $config type juggling by raising a TypeError for non-array decode results. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-06fix(self-update-command): resolve finder-related phase-b TODOsnsfisis
- Add Display for SplFileInfo (PHP (string) cast -> getPathname) and use it in clean_backups instead of a debug-format placeholder. - Generalize iterator_to_array's signature to preserve the element type so get_last_backup_version collects real SplFileInfo and returns the last basename, instead of mapping every entry to PhpMixed::Null. - Drop the stale builder-restructure TODO in get_old_installation_finder. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-06fix(array-merge): route mixed-key merges through faithful array_mergensfisis
* Config::merge called array_merge_recursive where PHP uses plain array_merge (string-key overwrite); switch those six sites to array_merge. * provides/replaces merges that may carry an AliasPackage's self.version numeric keys ("0","1",...) were collapsing under naive chain/insert/or_insert; route them through a new array_merge_map(). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-05refactor(json): make json encode helpers accept serde::Serializensfisis
Change json_encode/json_encode_ex and JsonFile::encode/encode_with_options to take a generic serde::Serialize value instead of &PhpMixed, implement Serialize for PhpMixed/ArrayObject, and drop the PhpMixed::String wrapping at JsonManipulator call sites in favor of passing raw values. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-03feat(php-shim): align fwrite/touch2/PHP_OS_FAMILY/PHP_URL_SCHEME with PHPnsfisis
Adjust fwrite to return int|false equivalent (Option<i64>), add touch2 with mtime, implement PHP_OS_FAMILY via std::env::consts::OS, and swap the PHP_URL_HOST placeholders for the now-available PHP_URL_SCHEME. Wire these into locker, filesystem, platform, and remote_filesystem. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-22refactor(php-shim): remove unnecessary methodsnsfisis
2026-05-20fix(compile): fix all remaining compile errorsnsfisis
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-19fix(compile): fix more random compile errorsnsfisis
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-19fix(compile): fix various compile errorsnsfisis
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-18fix(compile): impl std::error::Error for custom error typesnsfisis
2026-05-17chore: cargo clippy --fixnsfisis
2026-05-17fix(php-shim): add missing stub functions, constants, and typesnsfisis
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-17fix(class-map-generator): introduce CaptureKey enum and fix ↵nsfisis
class-map-generator compile errors - Add CaptureKey enum to Preg stub for typed capture access (by index or name) - Expand Preg stub with complete method set matching the PHP Composer\Pcre\Preg API - Update class-map-generator, php-file-cleaner, and php-file-parser to use new API - Add Display impls for exception types in shirabe-php-shim - Add follow_links/exclude stubs to Finder and new/get_pathname stubs to SplFileInfo Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-17fix(php-shim): resolve duplicate definitions and compile errorsnsfisis
- Remove duplicate function/constant definitions that were added during porting (strpos, str_contains, str_starts_with, is_scalar, strlen, substr, strtoupper, str_replace, sprintf, array_keys, str_ends_with, is_int, array_values, is_object, is_numeric, PHP_EOL, FILTER_VALIDATE_EMAIL, PHP_VERSION_ID) - Replace old spl_autoload_register/unregister (PhpMixed args) with typed Box<dyn Fn> versions - Replace old array_pop/array_shift/array_unshift/array_splice with generic/correctly-typed versions - Replace old trim(chars: &str) with trim(chars: Option<&str>) - Rename array_slice(PhpMixed) to array_slice_mixed to coexist with the typed array_slice<V>(IndexMap<String, V>) version - Fix chdir return type Result<()> -> anyhow::Result<()> - Add anyhow dependency to shirabe-php-shim
2026-05-17chore(style): cargo fmtnsfisis
2026-05-17feat(port): port ClassMapGenerator.phpnsfisis
2026-05-17feat(port): port PhpFileParser.phpnsfisis
2026-05-17feat(port): port Intervals.phpnsfisis
Add Clone derives to Constraint, Interval, and DevConstraintSet (needed for IntervalCollection). Add preg_match/preg_replace/preg_split stubs to shirabe-php-shim. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16feat(port): port Constraint.phpnsfisis
2026-05-16feat(port): port Bound.phpnsfisis
2026-05-16feat(port): port Solver.phpnsfisis
2026-05-16feat(port): port PlatformRepository.phpnsfisis
2026-05-16feat(port): port EventDispatcher.phpnsfisis