Skip to content

fix(factory): reject composite callable parameter types without Reflection method errors #50

Closed

Description

@coisa

Problem

CallableFactory checks for ReflectionType and then calls isBuiltin()/getName(). Those methods only exist on ReflectionNamedType, not ReflectionUnionType or ReflectionIntersectionType. A valid callable with a union/intersection parameter therefore triggers an engine Error instead of the factory's descriptive invalid-parameter exception.

Evidence / executed reproduction

Audited commit 67865fa35231c11e38c9facbfe775e0c5fbe2461.
CallableFactory.php:83–97.
On PHP 8.4.26, invoking:

$factory = new CallableFactory(fn(DateTime|DateTimeImmutable $value) => $value);
$factory($container);

produces Error: Call to undefined method ReflectionUnionType::isBuiltin() before any container lookup. No remote operation performed.

Expected / acceptance criteria

The existing documented scope is named class/interface arguments; this task does not request union/intersection autowiring support. Guard with ReflectionNamedType before using named-type methods and reject unsupported composite types through the existing RuntimeException::forInvalidParameterType path. Add union, intersection and DNF regression cases, as well as the existing scalar/untyped checks.

Priority P3; confidence high, dynamically reproduced with unmodified source. Direct callers currently cannot handle this using the documented factory error convention; ServiceProviderContainer may wrap the engine error, but the diagnostic remains incorrect.

Dedupe: reviewed all current and historical issues/PRs (#5–#49). This is independent of extension composition #48/#49 and native constructor autowiring #17/#18. No code, merge, release or deployment changes were made.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions