mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-02 21:41:19 +08:00
Fixes #15802: Fixed exception class in yii\di\Container
This commit is contained in:
committed by
Alexander Makarov
parent
dad0938918
commit
633d6b93b8
@ -17,6 +17,7 @@ Yii Framework 2 Change Log
|
||||
- Bug #16006: Handle case when `X-Forwarded-Host` header have multiple hosts separated with a comma (pgaultier)
|
||||
- Bug #16010: Fixed `yii\filters\ContentNegotiator` behavior when GET parameters contain an array (rugabarbo)
|
||||
- Bug #14660: Fixed `yii\caching\DbCache` concurrency issue when set values with the same key (rugabarbo)
|
||||
- Bug #15802: Fixed exception class in yii\di\Container (vuchastyi, developeruz)
|
||||
- Bug #15988: Fixed bash completion (alekciy)
|
||||
- Bug #15798: Fixed render `yii\grid\RadioButtonColumn::$content` and `yii\grid\CheckboxColumn::$content` (lesha724)
|
||||
- Bug #15548: Fixed index names collision in RBAC (gonimar)
|
||||
|
||||
@ -256,6 +256,7 @@ class Container extends Component
|
||||
unset($this->_singletons[$class]);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a class definition with this container and marks the class as a singleton class.
|
||||
*
|
||||
@ -417,6 +418,7 @@ class Container extends Component
|
||||
* Returns the dependencies of the specified class.
|
||||
* @param string $class class name, interface name or alias name
|
||||
* @return array the dependencies of the specified class.
|
||||
* @throws InvalidConfigException if a dependency cannot be resolved or if a dependency cannot be fulfilled.
|
||||
*/
|
||||
protected function getDependencies($class)
|
||||
{
|
||||
@ -425,7 +427,11 @@ class Container extends Component
|
||||
}
|
||||
|
||||
$dependencies = [];
|
||||
try {
|
||||
$reflection = new ReflectionClass($class);
|
||||
} catch (\ReflectionException $e) {
|
||||
throw new InvalidConfigException('Failed to instantiate component or class "' . $class . '".', 0, $e);
|
||||
}
|
||||
|
||||
$constructor = $reflection->getConstructor();
|
||||
if ($constructor !== null) {
|
||||
|
||||
@ -260,6 +260,7 @@ class ContainerTest extends TestCase
|
||||
'qux.using.closure' => function () {
|
||||
return new Qux();
|
||||
},
|
||||
'rollbar', 'baibaratsky\yii\rollbar\Rollbar'
|
||||
]);
|
||||
$container->setDefinitions([]);
|
||||
|
||||
@ -271,6 +272,14 @@ class ContainerTest extends TestCase
|
||||
$this->assertEquals('item1', $traversable->current());
|
||||
|
||||
$this->assertInstanceOf('yiiunit\framework\di\stubs\Qux', $container->get('qux.using.closure'));
|
||||
|
||||
try {
|
||||
$container->get('rollbar');
|
||||
$this->fail('InvalidConfigException was not thrown');
|
||||
} catch(\Exception $e)
|
||||
{
|
||||
$this->assertInstanceOf('yii\base\InvalidConfigException', $e);
|
||||
}
|
||||
}
|
||||
|
||||
public function testContainerSingletons()
|
||||
|
||||
Reference in New Issue
Block a user