Skip to content

Commit 1b1684e

Browse files
Fixed issues with string callables throwing exception on PSR-11 container
1 parent c1b247a commit 1b1684e

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

CHANGELOG-0.x.md

+5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
All notable changes to this project will be documented in this file.
44
Updates should follow the [Keep a CHANGELOG](https://keepachangelog.com/) principles.
55

6+
## [0.9.1] - 2020-10-11
7+
### Fixed
8+
- Fixed issues with string callables throwing exception on PSR-11 containers
9+
610
## [0.9.0] - 2020-10-05
711
### Added
812
- Added `DivineNii\Invoker\Interfaces\ArgumentValueResolverInterface` for `DivineNii\Invoker\ArgumentResolver` class
@@ -37,6 +41,7 @@ Updates should follow the [Keep a CHANGELOG](https://keepachangelog.com/) princi
3741
### Added
3842
- Initial commit
3943

44+
[0.9.1]: https://github.com/divineniiquaye/php-invoker/compare/v0.9.0...v0.9.1
4045
[0.9.0]: https://github.com/divineniiquaye/php-invoker/compare/v0.1.2...v0.9.0
4146
[0.1.2]: https://github.com/divineniiquaye/php-invoker/compare/v0.1.1...v0.1.2
4247
[0.1.1]: https://github.com/divineniiquaye/php-invoker/compare/v0.1.0...v0.1.1

src/CallableResolver.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,8 @@ public function resolve($callable)
7272
return $this->resolve($this->container->get($callable));
7373
} catch (NotFoundExceptionInterface $e) {
7474
if ($this->container->has($callable)) {
75-
throw $e;
75+
throw NotCallableException::fromInvalidCallable($callable, true);
7676
}
77-
78-
throw NotCallableException::fromInvalidCallable($callable, true);
7977
}
8078
}
8179

tests/CallableResolverTest.php

+7-2
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,13 @@ public function testResolveWithContainerHasAndException($unResolved): void
109109
$container->method('has')->with('handler')->willReturn(true);
110110
$container->method('get')->willThrowException(self::notFoundException());
111111

112-
$this->expectExceptionMessage('Is not a callable, yeah.');
113-
$this->expectException(NotFoundExceptionInterface::class);
112+
if (is_array($unResolved)) {
113+
$this->expectExceptionMessage('Is not a callable, yeah.');
114+
$this->expectException(NotFoundExceptionInterface::class);
115+
} else {
116+
$this->expectExceptionMessage('\'handler\' is neither a callable nor a valid container entry');
117+
$this->expectException(NotCallableException::class);
118+
}
114119

115120
$factory = new CallableResolver($container);
116121
$factory->resolve($unResolved);

0 commit comments

Comments
 (0)