public function testArrayAccess() { $container = new \Pure\Container(); $di = new \Pure\DI($container, $this->provider); $di['object3'] = $this; $this->assertTrue($di->has('object3')); $this->assertSame($this, $di['object3']); $this->assertTrue(isset($di['object3'])); $this->assertFalse(isset($di['object4'])); unset($di['object3']); $this->assertFalse($container->has('object3')); $this->assertFalse($this->provider->has('object3')); }
/** * 销毁一个服务, 该方法将清除容器内对象和对象提供者实例对应内容 * * @param string $name */ public function destroy($name) { $this->_container->has($name) and $this->_container->destroy($name); $this->_provider->has($name) and $this->_provider->destroy($name); }