Skip to content

Support named first arguments in delegated assertions - #357

Open
ac1982 wants to merge 1 commit into
beberlei:masterfrom
ac1982:fix/named-delegated-arguments
Open

ac1982 wants to merge 1 commit into
beberlei:masterfrom
ac1982:fix/named-delegated-arguments

Conversation

@ac1982

@ac1982 ac1982 commented Oct 20, 2026

Copy link
Copy Markdown

Assertion::nullOrString(value: $value) throws “Missing the first argument” on PHP 8 because the magic dispatcher only checks argument index 0. The same problem affects the all… variants.

Resolve the first parameter name from the underlying assertion (including subclass overrides), move that argument into the existing value slot, and preserve the remaining named arguments for PHP to bind. This supports reordered arguments and assertions whose first parameter is named countable, while retaining native duplicate/unknown argument errors.

Fixes #343.

Regression tests cover both delegates, null and iterable values, reordered/mixed arguments, subclass parameter names, and failure details. On the original implementation, 11 of the initial 14 regression cases error. With the change, PHPUnit passes 544 tests / 944 assertions with 3 skips for the unavailable intl extension (PHP 8.5.4, PHPUnit 9.6.38).

composer assert:cs-lint cannot run with the currently resolved fixer 3 because the existing .php_cs configuration is obsolete. Running fixer 2.19.3 against the changed files reports the same preexisting formatting changes as the clean base. Other PHP versions were not run locally; the new tests skip named-argument calls on PHP 7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

nullOr methods do not work with named arguments

1 participant