本文整理汇总了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();
}
示例2: getInstance
public static function getInstance($dbSetting = 'default')
{
if (is_null(static::$instance)) {
static::$instance = new static($dbSetting);
}
return static::$instance;
}
示例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;
}
示例4: instance
/**
* @return Settings
*/
static function instance()
{
if (!static::$instance) {
static::$instance = new Settings();
}
return static::$instance;
}
示例5: getInstance
/**
* Init the class.
*
* @return \THFWK_ThemosisTheme
*/
public static function getInstance()
{
if (is_null(static::$instance)) {
static::$instance = new static();
}
return static::$instance;
}
示例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;
}
示例7: self
static function get_instance()
{
if (is_null(static::$instance)) {
static::$instance = new self();
}
return static::$instance;
}
示例8: __construct
/**
* Constructor.
*
* @param \wpdb $db
*/
public function __construct(wpdb $db)
{
if (!isset(static::$instance)) {
static::$instance = $this;
static::$db = $db;
}
}
示例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;
}
示例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;
}
示例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;
}
示例12: get
public function get()
{
if (!isset(static::$instance)) {
static::$instance = new self();
}
return static::$instance;
}
示例13: log
public static function log($func, $args)
{
if (static::$instance === null) {
static::$instance = new static();
}
$res = static::$log->{$func}(...$args);
}
示例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;
}
示例15: instance
/**
* @return $instance
*/
public static function instance()
{
if (static::$instance === null) {
static::$instance = new static();
}
return static::$instance;
}