Skip to content

Commit

Permalink
Use interface for default resolver if instantiable
Browse files Browse the repository at this point in the history
Signed-off-by: Tom Wright <tom@inflatablecookie.com>
  • Loading branch information
betterthanclay committed Oct 30, 2023
1 parent 739f6b0 commit f81213e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
* Use interface for default resolver if instantiable

## v0.2.14 (2023-10-29)
* Added default resolver interface for nameless resolution
* Refactored package file structure
Expand Down
7 changes: 7 additions & 0 deletions src/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,13 @@ class_exists($name) &&
// Make sure there's at least one resolver for interface
$this->ensureResolver($interface);

if (
$name === null &&
(new ReflectionClass($interface))->isInstantiable()
) {
$name = $interface;
}

if ($name !== null) {
$name = $this->normalize($interface, $name);
}
Expand Down

0 comments on commit f81213e

Please sign in to comment.