feat/parse url - #667
Merged
Merged
Conversation
nahime0
marked this pull request as ready for review
August 6, 2026 08:27
Member
Author
|
@greptile-apps review this |
Greptile SummaryAdds PHP-compatible
Confidence Score: 5/5The PR appears safe to merge based on the inspected parsing, ABI, ownership, exception, and cross-target behavior. The native and eval implementations consistently materialize PHP-compatible result shapes, preserve the expected runtime layouts, and are exercised by a shared edge-case corpus; no actionable changed-code failure remains.
|
| Filename | Overview |
|---|---|
| crates/elephc-magician/src/interpreter/builtins/string/parse_url.rs | Adds the eval builtin, PHP-compatible byte scanner, result materialization, and fixture-driven parity tests; no actionable defect was established. |
| src/builtins/string/parse_url.rs | Registers the AOT builtin and refines static selector result types while retaining Mixed for dynamic selectors. |
| src/codegen/lower_inst/builtins/strings.rs | Lowers URL and selector operands into the architecture-specific runtime ABI without an established register-preservation defect. |
| src/codegen_support/runtime/strings/parse_url.rs | Emits scanner support, static component keys, and catchable ValueError construction for both targets. |
| src/codegen_support/runtime/strings/parse_url/aarch64.s | Implements AArch64 parsing, component copying, Mixed boxing, and associative-hash construction with consistent ABI usage. |
| src/codegen_support/runtime/strings/parse_url/x86_64.s | Implements the corresponding x86_64 scanner and result construction with no concrete architecture divergence found. |
| tests/fixtures/parse_url_cases.json | Provides shared PHP-derived coverage for standard forms, invalid authorities and ports, empty components, IPv6, and control-byte substitution. |
| Cargo.lock | Adds the existing serde_json package to the Magician dependency list without changing the advisory-flagged dependency versions. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["PHP parse_url(url, component)"] --> B{"Execution path"}
B -->|AOT| C["EIR RuntimeFnId::ParseUrl"]
C --> D["Target-aware lowering"]
D --> E["AArch64 / x86_64 scanner"]
B -->|eval| F["Magician builtin registry"]
F --> G["Rust URL scanner"]
E --> H{"Parse result"}
G --> H
H -->|Invalid URL| I["false"]
H -->|Negative selector| J["Associative component array"]
H -->|Selector 0–7| K["string / int / null"]
H -->|Selector > 7| L["ValueError"]
Reviews (1): Last reviewed commit: "docs: add parse_url implementation plan" | Re-trigger Greptile
Guikingone
reviewed
Aug 6, 2026
|
Too many files changed for review (199 files, 100 file limit). Bypass the limit by tagging |
Guikingone
added a commit
to Guikingone/elephc
that referenced
this pull request
Aug 7, 2026
Brings in parse_url (illegalstudio#667) and the by-ref foreach borrowed-source fixes (illegalstudio#648), 15 upstream commits in all. Every conflict was a GENERATED builtin page — 152 files under `docs/php/builtins` and `docs/internals/builtins`, and no source file at all. They were resolved the only way generated files can be: by regenerating them from the two registries with `cargo build --example gen_builtins` + `scripts/docs/extract_builtins.py --render --force`, not by picking a side. 494 builtins, 962 pages; both CI audits (`audit_builtins.py`, `validate_site_compat.py`) report 0 errors.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds PHP-compatible
parse_url()on both the AOT compiler path and the Magicianeval()runtime, plus the predefinedPHP_URL_*constants.src/builtins/string/parse_url.rs) →RuntimeFnId::ParseUrl→ Mixed-returning__rt_parse_urlscanner (AArch64 + x86_64) with associative-array and component-selector results, Fresh ownership, and catchableValueErrorfor invalid selectors.eval_builtin!home file with a pure-Rust scanner aligned to PHP 8.4ext/standard/url.cquirks (scheme-relative URLs, IPv6 brackets, empty present components, control-byte substitution, port range checks).PHP_URL_SCHEME…PHP_URL_FRAGMENT(0–7) wired through checker, prescan, name resolver, autoload interpreter, Magician predefined constants, README, and docs.tests/fixtures/parse_url_cases.jsonexercised by Magician unit tests and AOT codegen tests; coverage also includes component shapes, named/callable call sites, invalid URLs (false), selectorValueError, and heap-debug ownership.Behavior notes
parse_url($url)/ negative componentportas int)falsePHP_URL_PORTintnullfalsePHP_URL_*string(may be"")nullfalseSelectors greater than
PHP_URL_FRAGMENTraise:parse_url(): Argument #2 ($component) must be a valid URL component identifier, N givenAny negative component selects the full-array form (PHP 8.4). Invalid URLs return
falseeven when the selector would otherwise be invalid.Test plan
cargo buildcargo test --test codegen_tests parse_urlcargo test --test error_tests parse_urlcargo test -p elephc-magician parse_urlgit diff --checkELEPHC_PHP_CHECK=1 cargo test --test codegen_tests parse_urlDocs / examples
docs/php/strings.md, generated builtin pages, internals runtime noteexamples/parse-url/main.phpCHANGELOG.md[Unreleased]entry