当前位置: 首页>>代码示例>>PHP>>正文


PHP Container::has方法代码示例

本文整理汇总了PHP中Container::has方法的典型用法代码示例。如果您正苦于以下问题:PHP Container::has方法的具体用法?PHP Container::has怎么用?PHP Container::has使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Container的用法示例。


在下文中一共展示了Container::has方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: test1

 public function test1()
 {
     $container = new Container();
     $container->set('scalar', 42);
     $this->assertEquals(42, $container->get('scalar'));
     $this->assertTrue($container->has('scalar'));
     $this->assertFalse($container->has('scalaR'));
 }
开发者ID:cerad,项目名称:di,代码行数:8,代码来源:ContainerTest.php

示例2: testHasAndRemove

 /**
  * @param mixed $definition
  *
  * @dataProvider providerDefinitions
  */
 public function testHasAndRemove($definition)
 {
     $di = new Container();
     $di->set('test', $definition);
     $this->assertTrue($di->has('test'));
     $di->remove('test');
     $this->assertFalse($di->has('test'));
 }
开发者ID:lebran,项目名称:container,代码行数:13,代码来源:ContainerTest.php

示例3: testHasGet

 /**
  * @todo Implement testHas().
  */
 public function testHasGet()
 {
     $expect = new \StdClass();
     $this->container->set('foo', $expect);
     $this->assertTrue($this->container->has('foo'));
     $this->assertFalse($this->container->has('bar'));
     $actual = $this->container->get('foo');
     $this->assertSame($expect, $actual);
 }
开发者ID:walterjrp,项目名称:form-builder,代码行数:12,代码来源:ContainerTest.php

示例4:

 /**
  * Returns true if key exists in langs array
  *
  * @param string $name
  * @return boolean
  */
 function lang_exists($name)
 {
     if (is_null($name)) {
         return false;
     } else {
         return $this->langs->has($name);
     }
 }
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:14,代码来源:Localization.class.php

示例5: __construct

 /**
  * Constructor
  *
  * Instantiate the service locator object.
  *
  * @param  array $services
  */
 public function __construct(array $services = null)
 {
     if (null !== $services) {
         $this->setServices($services);
     }
     if (!Container::has('default')) {
         Container::set('default', $this);
     }
 }
开发者ID:popphp,项目名称:popphp,代码行数:16,代码来源:Locator.php

示例6: testCreate

 /**
  * @covers ::__construct
  * @covers ::initContainer
  * @covers ::register
  * @covers ::has
  * @covers ::get
  * @covers Nora\Core\DI\Exception\InstanceNotFound::__construct
  * @expectedException Nora\Core\DI\Exception\InstanceNotFound
  */
 public function testCreate()
 {
     $c = new Container();
     $c->register(['hOge' => function () {
         return new \StdClass();
     }]);
     $this->assertTrue($c->has('Hoge'));
     $this->assertInstanceOf('StdClass', $c->get('hogE'));
     $c->get('Hoge')->cnt = 0;
     $c->get('hoGe')->cnt++;
     $c->on('di.container.pre_get', function ($e) {
         if (strtolower($e->name) === 'phpunit') {
             $e->instance = $this;
         }
     });
     $this->assertEquals($this, $c->get('phpUnit'));
     $c->get('InvalidName');
 }
开发者ID:nora-worker,项目名称:core,代码行数:27,代码来源:ContainerTest.php

示例7: has

 /**
  * Returns true if the given service is defined.
  *
  * @param  string  $id      The service identifier
  *
  * @return Boolean true if the service is defined, false otherwise
  */
 public function has($id)
 {
     return isset($this->definitions[$id]) || isset($this->aliases[$id]) || parent::has($id);
 }
开发者ID:bill97420,项目名称:symfony,代码行数:11,代码来源:Builder.php

示例8: testRemove

 /**
  * @param Container $container
  * @depends testMakeContainer
  */
 public function testRemove(Container $container)
 {
     $this->assertEquals('H', $container->remove('h'));
     $this->assertFalse($container->has('h'));
 }
开发者ID:chemisus,项目名称:container,代码行数:9,代码来源:ObjectContainerTest.php


注:本文中的Container::has方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。