Skip to content

Check partial-application bound arguments in the creating scope#182

Closed
iliaal wants to merge 5 commits into
masterfrom
fix/pfa-bound-arg-strict-types
Closed

Check partial-application bound arguments in the creating scope#182
iliaal wants to merge 5 commits into
masterfrom
fix/pfa-bound-arg-strict-types

Conversation

@iliaal

@iliaal iliaal commented Jul 17, 2026

Copy link
Copy Markdown
Owner

The bound-argument type check in zp_bind() resolved strict_types from ZEND_ARG_USES_STRICT_TYPES(), which reads the caller of the frame creating the partial rather than the file where the partial is written. So the same f("3", ?) under strict_types=1 threw when written inside a function but silently coerced at top level, and the resulting TypeError named the enclosing function rather than the target. This passes the creating frame's strict_types into the check via ZEND_FLF_ARG_USES_STRICT_TYPES and attributes the error to the target function with zend_argument_type_error_ex.

The RFC does not specify creation-time bound-argument type-check semantics, so the proposed behavior (check eagerly against the creating scope's strict_types, with the error attributed to the target function) is a proposal for confirmation, not a settled fix.

Sjord and others added 5 commits July 17, 2026 14:30
Assert and take advantage of that size is always 1. This is also documented in [the curl docs](https://curl.se/libcurl/c/CURLOPT_READFUNCTION.html). So there is no need to multiply with size, so this can be removed.

I started this to see whether size * nmemb can overflow. This makes it clear that it cannot.
And instead let the normal docref error handling code handle arguments
Bound-argument type checks in zp_bind() resolved strict_types from
ZEND_ARG_USES_STRICT_TYPES(), which reads the caller of the frame
creating the partial rather than the file where the partial is written,
so the same f("3", ?) threw at one call depth and silently coerced at
another, and the TypeError named the enclosing function instead of the
target. Pass the creating frame's strict_types explicitly and attribute
the error to the target function.
@iliaal
iliaal force-pushed the fix/pfa-bound-arg-strict-types branch from 189f0c7 to ba1b308 Compare July 17, 2026 14:59
@iliaal

iliaal commented Jul 17, 2026

Copy link
Copy Markdown
Owner Author

Promoted upstream: php#22789.

@iliaal iliaal closed this Jul 17, 2026
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.

3 participants