Skip to content

Container: fail clearly on an unbound interface or abstract class - #435

Merged
papac merged 1 commit into
5.xfrom
refactor/code-base
Oct 17, 2026
Merged

papac merged 1 commit into
5.xfrom
refactor/code-base

Conversation

@papac

@papac papac commented Oct 17, 2026

Copy link
Copy Markdown
Member

Capsule::resolve() returned the key itself when the class was not instantiable, so make() on an interface or abstract class with no binding handed back the type's name as a string. Callers expecting an instance broke far from the cause, most visibly as "Compass::getInjectParameter(): Return value must be of type ?object, string returned" when a controller constructor depended on an interface nobody had bound.

resolve() now throws ContainerException::notInstantiable(), whose message names the type, says whether it is an interface or an abstract class, and shows the bind() call to add. Covers make(), makeWith() and dependencies resolved while building another class.

Capsule::resolve() returned the key itself when the class was not
instantiable, so make() on an interface or abstract class with no binding
handed back the type's *name* as a string. Callers expecting an instance
broke far from the cause, most visibly as "Compass::getInjectParameter():
Return value must be of type ?object, string returned" when a controller
constructor depended on an interface nobody had bound.

resolve() now throws ContainerException::notInstantiable(), whose message
names the type, says whether it is an interface or an abstract class, and
shows the bind() call to add. Covers make(), makeWith() and dependencies
resolved while building another class.
@papac
papac merged commit ae6c38a into 5.x Oct 17, 2026
17 checks passed
@papac
papac deleted the refactor/code-base branch October 17, 2026 02:39
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.

1 participant