本文整理汇总了PHP中Parameter::named方法的典型用法代码示例。如果您正苦于以下问题:PHP Parameter::named方法的具体用法?PHP Parameter::named怎么用?PHP Parameter::named使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Parameter
的用法示例。
在下文中一共展示了Parameter::named方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_RegisterWithFactoryParam_ResolveNamed
public function test_RegisterWithFactoryParam_ResolveNamed()
{
$counter = 0;
$this->registerType('Test\\ClassA')->named('test')->onActivated(function () use(&$counter) {
$counter++;
});
$this->registerType('ClassN22')->withParams(Parameter::named('test'));
$c = $this->resolve('ClassN22');
$this->assertEquals(0, $counter);
$c->a->createInstance();
$this->assertEquals(1, $counter);
}
示例2: testResolvingNamedParameters
public function testResolvingNamedParameters()
{
$this->builder->registerType('ClassZ')->withParams(Parameter::def(), 'z', Parameter::named('test2'));
$this->builder->registerType('ClassE')->withParams('test1');
$this->builder->registerType('ClassE')->withParams('test2')->named('test2');
$container = $this->builder->build();
$z = $container->resolve('ClassZ');
$this->assertEquals('test1', $container->resolve('ClassE')->value);
$this->assertEquals('test2', $container->resolveNamed('test2')->value);
$this->assertEquals('test1', $z->e1->value);
$this->assertEquals('z', $z->value);
$this->assertEquals('test2', $z->e2->value);
}