當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。