Completed
Push — 6.0 ( 8a13c8...ac9700 )
by liu
09:00
created

src/think/facade/Cache.php (1 issue)

Labels
Severity
1
<?php
2
// +----------------------------------------------------------------------
3
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
4
// +----------------------------------------------------------------------
5
// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved.
6
// +----------------------------------------------------------------------
7
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
8
// +----------------------------------------------------------------------
9
// | Author: liu21st <[email protected]>
10
// +----------------------------------------------------------------------
11
declare (strict_types = 1);
12
13
namespace think\facade;
14
15
use think\cache\Driver;
16
use think\cache\TagSet;
17
use think\Facade;
0 ignored issues
show
This use statement conflicts with another class in this namespace, think\facade\Facade. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
18
19
/**
20
 * @see \think\Cache
21
 * @package think\facade
22
 * @mixin \think\Cache
23
 * @method static string|null getDefaultDriver() 默认驱动
24
 * @method static mixed getConfig(null|string $name = null, mixed $default = null) 获取缓存配置
25
 * @method static array getStoreConfig(string $store, string $name = null, null $default = null) 获取驱动配置
26
 * @method static Driver store(string $name = null) 连接或者切换缓存
27
 * @method static bool clear() 清空缓冲池
28
 * @method static mixed get(string $key, mixed $default = null) 读取缓存
29
 * @method static bool set(string $key, mixed $value, int|\DateTime $ttl = null) 写入缓存
30
 * @method static bool delete(string $key) 删除缓存
31
 * @method static iterable getMultiple(iterable $keys, mixed $default = null) 读取缓存
32
 * @method static bool setMultiple(iterable $values, null|int|\DateInterval $ttl = null) 写入缓存
33
 * @method static bool deleteMultiple(iterable $keys) 删除缓存
34
 * @method static bool has(string $key) 判断缓存是否存在
35
 * @method static TagSet tag(string|array $name) 缓存标签
36
 */
37
class Cache extends Facade
38
{
39
    /**
40
     * 获取当前Facade对应类名(或者已经绑定的容器对象标识)
41
     * @access protected
42
     * @return string
43
     */
44
    protected static function getFacadeClass()
45
    {
46
        return 'cache';
47
    }
48
}
49