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