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


PHP static::instance方法代码示例

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


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

示例1: getInstance

 /**
  * Get instance 
  *
  * @return static
  */
 public static function getInstance()
 {
     if (!static::$instance instanceof static) {
         static::$instance = new static();
     }
     return static::$instance->getConnection();
 }
开发者ID:dilbadil,项目名称:phpbridge,代码行数:12,代码来源:Db.php

示例2: getInstance

 public static function getInstance($dbSetting = 'default')
 {
     if (is_null(static::$instance)) {
         static::$instance = new static($dbSetting);
     }
     return static::$instance;
 }
开发者ID:foreverphp,项目名称:framework,代码行数:7,代码来源:SQLEngine.php

示例3: instance

 /**
  * Returns the implementation implementation registered with the Facade.
  *
  * @return Xaamin\Whatsapi\Contracts\WhatsapiInterface
  */
 public static function instance()
 {
     if (!static::$instance) {
         static::$instance = forward_static_call_array(array(get_called_class(), 'create'), func_get_args());
     }
     return static::$instance;
 }
开发者ID:shinichi81,项目名称:whatsapi-1,代码行数:12,代码来源:Facade.php

示例4: instance

 /**
  * @return Settings
  */
 static function instance()
 {
     if (!static::$instance) {
         static::$instance = new Settings();
     }
     return static::$instance;
 }
开发者ID:Max201,项目名称:nanocore,代码行数:10,代码来源:Settings.php

示例5: getInstance

 /**
  * Init the class.
  *
  * @return \THFWK_ThemosisTheme
  */
 public static function getInstance()
 {
     if (is_null(static::$instance)) {
         static::$instance = new static();
     }
     return static::$instance;
 }
开发者ID:dannywilson,项目名称:themosis-theme,代码行数:12,代码来源:functions.php

示例6: instance

 /**
  * @param null $args
  * @return self
  */
 public static function instance($args = null)
 {
     if (null === static::$instance) {
         static::$instance = new static($args);
     }
     return static::$instance;
 }
开发者ID:xoka,项目名称:php2-Blog,代码行数:11,代码来源:Singleton.php

示例7: self

 static function get_instance()
 {
     if (is_null(static::$instance)) {
         static::$instance = new self();
     }
     return static::$instance;
 }
开发者ID:khromov,项目名称:Splitdown,代码行数:7,代码来源:Splitdown.php

示例8: __construct

 /**
  * Constructor.
  * 
  * @param \wpdb $db
  */
 public function __construct(wpdb $db)
 {
     if (!isset(static::$instance)) {
         static::$instance = $this;
         static::$db = $db;
     }
 }
开发者ID:wells5609,项目名称:wp-app,代码行数:12,代码来源:Connection.php

示例9: get_instance

 /**
  * Get class instance.
  *
  * @since  1.0
  * @return JB_Lib instance
  * @author JACK BUI
  */
 public static function get_instance()
 {
     if (NULL == static::$instance) {
         static::$instance = new static();
     }
     return static::$instance;
 }
开发者ID:jackbui2014,项目名称:JB-Onepage-Simple-theme,代码行数:14,代码来源:class-section-about.php

示例10: instance

 /**
  * Get a instance.
  *
  * @return \Jobqueue\Context
  */
 public static function instance()
 {
     if (is_null(static::$instance)) {
         static::$instance = new static(\Fuel::$env, \Config::load('jobqueue', 'jobqueue'));
     }
     return static::$instance;
 }
开发者ID:hosopy,项目名称:fuel-jobqueue,代码行数:12,代码来源:context.php

示例11: getInstance

 /**
  * Returns the singleton instance of this class.
  *
  * @param mixed $args,... Additional arguments.
  * @return self The singleton instance.
  */
 public static function getInstance(...$args)
 {
     if (static::$instance === null) {
         static::$instance = new static(...$args);
     }
     return static::$instance;
 }
开发者ID:johnnyos,项目名称:johnnyos,代码行数:13,代码来源:AbstractSingleton.php

示例12: get

 public function get()
 {
     if (!isset(static::$instance)) {
         static::$instance = new self();
     }
     return static::$instance;
 }
开发者ID:erkmen,项目名称:wpstartersetup,代码行数:7,代码来源:Ajax.php

示例13: log

 public static function log($func, $args)
 {
     if (static::$instance === null) {
         static::$instance = new static();
     }
     $res = static::$log->{$func}(...$args);
 }
开发者ID:reservat,项目名称:core,代码行数:7,代码来源:Log.php

示例14: testBootstrap

 /**
  * Test the cache can be bootstrapped when using the redis driver.
  *
  * @covers Molovo\Amnesia\Cache::bootstrap
  * @covers Molovo\Amnesia\Cache\Instance::__construct
  * @covers Molovo\Amnesia\Driver\File::__construct
  * @covers Molovo\Amnesia\Cache::instance
  */
 public function testBootstrap()
 {
     $name = 'file_driver_test';
     $config = [$name => ['driver' => 'file', 'store_path' => dirname(dirname(__DIR__)) . '/_data/cache/store']];
     if (!is_dir($config[$name]['store_path'])) {
         // This is a test cache, so just let anyone write to it
         // to avoid having to deal with permissions issues
         mkdir($config[$name]['store_path'], 0777, true);
     }
     Cache::bootstrap($config);
     $instance = Cache::instance($name);
     verify($instance)->isInstanceOf(Instance::class);
     // Test that the driver has been instantiated correctly
     $property = new \ReflectionProperty(Instance::class, 'driver');
     $property->setAccessible(true);
     $driver = $property->getValue($instance);
     verify($driver)->isInstanceOf(File::class);
     // Call a second time to test retrieval from cache
     $cached_instance = Cache::instance($name);
     // Compare hashes of the two instances to ensure they are
     // the same object
     $hash1 = spl_object_hash($instance);
     $hash2 = spl_object_hash($cached_instance);
     verify($hash1)->equals($hash2);
     // Store the instance so we can use it in other tests
     static::$instance = $instance;
 }
开发者ID:molovo,项目名称:amnesia,代码行数:35,代码来源:FileTest.php

示例15: instance

 /**
  * @return $instance
  */
 public static function instance()
 {
     if (static::$instance === null) {
         static::$instance = new static();
     }
     return static::$instance;
 }
开发者ID:noremac13,项目名称:website,代码行数:10,代码来源:Service.php


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