feat(types): union types, intersection, DNF #199#637
Closed
kakserpom wants to merge 1 commit into
Closed
Conversation
eee5f3d to
37e2e32
Compare
Pull Request Test Coverage Report for Build 21821037952Details
💛 - Coveralls |
6d96b6e to
9b56970
Compare
Xenira
reviewed
Dec 28, 2025
Xenira
reviewed
Dec 28, 2025
3f757ac to
a6833e6
Compare
Contributor
Author
|
@Xenira ;-) |
81eea53 to
574de49
Compare
Contributor
Author
|
@ptondereau Rebased. Which one is next? |
8cbb7d2 to
62562bf
Compare
62562bf to
feeca86
Compare
feeca86 to
1ab5162
Compare
Member
|
Superseded by #734. Thanks for the help |
ptondereau
added a commit
that referenced
this pull request
Jun 2, 2026
Wires the slice-05 type-string parser into #[php_function],
#[php_impl] methods, and #[php_interface] trait methods so authors
can declare compound PHP types directly on Rust signatures, e.g.
`#[php(types = "int |string")]` on a parameter or
`#[php(returns = "(\\A & \\B) |\\C")]` on a function. The override is
the source of truth for the registered PHP type, including
nullability; runtime modifiers (default, as_ref, variadic) still
apply.
The macro emits `PhpType::from_str(LIT)` at extension load rather
than at expansion time because crates/macros cannot depend on the
runtime crate (cargo dep cycle: ext-php-rs -> ext-php-rs-derive).
This matches issue 06 acceptance criterion 4 ("re-emitting the
source string and parse()-ing at registration"). Compile-time
validation is restricted to syntactic checks (allowed character
set, non-empty, length cap) with a span on the LitStr. Parser-
rejected strings panic at first `cargo run` with the original
literal in the message. A follow-up captures extracting the parser
to a shared crate so all errors surface at build time.
Per-arg `#[php(...)]` attributes are stripped from the re-emitted
ItemFn so rustc never sees the unknown attribute (regression guard
for PR #637's bug). Function-level `#[php(...)]` was already
stripped; this extends the strip to FnArg::Typed.attrs.
Verification:
- 36 macro-crate unit tests (10 new): syntactic validation, runtime
emit shape, parser strip, span-on-bad-input.
- 29 integration tests including new tests/src/integration/
php_types_attr/ module covering primitive union, class union,
intersection (cfg(php83)), DNF (cfg(php83)), function returns,
and #[php_impl] method coverage on both arg and return.
- Pass on PHP 8.2 NTS (intersection/DNF cfg-skipped), 8.4 NTS,
8.4 ZTS via Reflection assertions.
- cargo fmt --check + cargo clippy --workspace --all-targets
-- -D warnings clean.
Closes issue #199 acceptance criteria for slice 06.
ptondereau
added a commit
that referenced
this pull request
Jun 2, 2026
Wires the slice-05 type-string parser into #[php_function],
#[php_impl] methods, and #[php_interface] trait methods so authors
can declare compound PHP types directly on Rust signatures, e.g.
`#[php(types = "int |string")]` on a parameter or
`#[php(returns = "(\\A & \\B) |\\C")]` on a function. The override is
the source of truth for the registered PHP type, including
nullability; runtime modifiers (default, as_ref, variadic) still
apply.
The macro emits `PhpType::from_str(LIT)` at extension load rather
than at expansion time because crates/macros cannot depend on the
runtime crate (cargo dep cycle: ext-php-rs -> ext-php-rs-derive).
This matches issue 06 acceptance criterion 4 ("re-emitting the
source string and parse()-ing at registration"). Compile-time
validation is restricted to syntactic checks (allowed character
set, non-empty, length cap) with a span on the LitStr. Parser-
rejected strings panic at first `cargo run` with the original
literal in the message. A follow-up captures extracting the parser
to a shared crate so all errors surface at build time.
Per-arg `#[php(...)]` attributes are stripped from the re-emitted
ItemFn so rustc never sees the unknown attribute (regression guard
for PR #637's bug). Function-level `#[php(...)]` was already
stripped; this extends the strip to FnArg::Typed.attrs.
Verification:
- 36 macro-crate unit tests (10 new): syntactic validation, runtime
emit shape, parser strip, span-on-bad-input.
- 29 integration tests including new tests/src/integration/
php_types_attr/ module covering primitive union, class union,
intersection (cfg(php83)), DNF (cfg(php83)), function returns,
and #[php_impl] method coverage on both arg and return.
- Pass on PHP 8.2 NTS (intersection/DNF cfg-skipped), 8.4 NTS,
8.4 ZTS via Reflection assertions.
- cargo fmt --check + cargo clippy --workspace --all-targets
-- -D warnings clean.
Closes issue #199 acceptance criteria for slice 06.
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.
Implements #199