Repository navigation
Description
Context
ServiceBasedPlugin::maybe_resolve() (src/Infrastructure/ServiceBasedPlugin.php:720-726) calls any value for which is_callable() is true. It is applied to service classes, binding targets, shared-instance entries, argument-map class names, delegation-map class names (:626) and argument names (:563). A plain string that happens to name a PHP function ('key', 'date', 'trim') is therefore executed with ( $injector, $container ) instead of being used as a value. Design principle 9: configuration arriving through filters is untrusted input.
The Web Stories plugin guards against bare function names (! ( is_string( $value ) && function_exists( $value ) )); that still executes 'Class::method' strings and [ $object, 'method' ] arrays.
Decision
Decision (maintainer, 2026-10-22): Choose option B: continue resolving any callable except bare function-name strings. In maybe_resolve(), execute a value only when is_callable($value) and not (is_string($value) && function_exists($value)). Preserve closures, callable static-method strings, callable arrays and invokable objects as deferred resolvers. Argument names are always literal and must not pass through deferred resolution. Callable argument values and explicit delegation factories keep their existing separate handling.
Compatibility ruling: approve the resulting behaviour change for generated plugins that used a bare function-name string as a deferred resolver; those callers must wrap the function in a closure or another supported callable form. Retain breaking to make this migration visible. This decision deliberately retains implicit method/array/invokable resolution.
Scope
- Apply the agreed function-name guard in
maybe_resolve(); strings excluded by that guard remain literal values and undergo the normal downstream validation. - Stop resolving argument names; keep the existing string-name validation.
- Document the supported deferred forms and migration for bare function-name resolvers in the composition-root guidance/docblocks.
Out of scope
- Lazily resolved argument values inside
SimpleInjector(a separate feature idea).
Acceptance criteria
- A string configuration value naming an existing PHP function is returned unchanged by deferred resolution, with no invocation; a regression fails before the change and passes after. Subsequent class/configuration validation remains in force.
- Argument names such as
key,dateandtrimremain literal, bind the intended argument, and never execute the corresponding function; regression coverage proves this. - Closures, callable static-method strings, callable arrays and invokable objects still resolve with the injector and container, with coverage for each form.
- Non-callable values remain unchanged.
- Callable argument values and explicit delegation factories retain their existing behaviour, with focused regression coverage.
- Composition-root guidance/docblocks document the accepted callable forms and how to migrate bare function-name resolvers.
Verification
composer test
composer lintImpact on generated plugins
Breaking behaviour change approved above: bare function-name strings no longer act as deferred resolvers. Wrap those functions in closures or another supported callable form. Existing method strings, callable arrays, invokable objects and closures continue to resolve. No public method signature changes are required. Argument values and delegation factories are unaffected.
Reproduction (2026-10-22)
Executed php -d error_reporting=22527 /tmp/scaffold-triage/repro.php on PHP 8.5.12 against an isolated git archive origin/main export at 055978329c94b0fbbda5832f582ee727ca7bdecd. The probe used the bundled autoloader, no Composer dependencies, and the stand-ins described below. This was a bounded triage probe, not a supported-runtime/full-suite verification.
On the reviewed commit, with a no-WordPress PHP probe, a subclass exposing parse_arguments() called it after new ProbePlugin(false) with [ProbePlugin::class => ['key' => 'literal']]. Expected: bind the literal argument name key; actual: ArgumentCountError: key() expects exactly 1 argument, 2 given. Calling the parser after construction isolates this from #21's uninitialized-container bug. Argument values and delegation factories are passed through intentionally (:560-569, :623-642); do not accidentally restrict those when resolving this issue.
Run the regression as a focused PHPUnit test, then the verification commands above. The maintainer selected the compatible callable guard in the decision above; the probe establishes the regression rather than the policy.
Updated 2026-10-22: triaged against origin/main at 055978329c94b0fbbda5832f582ee727ca7bdecd; factual checks and remaining gaps are recorded above.
Updated 2026-10-22: maintainer selected option B; callable policy, compatibility impact and checkable implementation criteria folded into the body.
Activity
schlessera commentedon Oct 22, 2026
Triage (2026-10-22): Confirmed the argument-name failure with a bounded PHP probe:
keyraises ArgumentCountError after construction. Added the missing delegation-key call site and distinguished deferred configuration from argument values/delegation factories. The callable policy and breaking-change ruling remain unresolved.schlessera commentedon Oct 22, 2026
Decision (maintainer, 2026-10-22): Choose option B: continue resolving any callable except bare function-name strings. In
maybe_resolve(), execute a value only whenis_callable($value)and not(is_string($value) && function_exists($value)). Preserve closures, callable static-method strings, callable arrays and invokable objects as deferred resolvers. Argument names are always literal and must not pass through deferred resolution. Callable argument values and explicit delegation factories keep their existing separate handling.Compatibility ruling: approve the resulting behaviour change for generated plugins that used a bare function-name string as a deferred resolver; those callers must wrap the function in a closure or another supported callable form. Retain
breakingto make this migration visible. This decision deliberately retains implicit method/array/invokable resolution.schlessera commentedon Oct 23, 2026
Picking this up on branch
fix/23-literal-function-name-config.