错误代码
语法解析错误: syntax error, unexpected 'const' (T_CONST), expecting variable (T_VARIABLE)
代码
class Psr16Cache implements CacheInterface, PruneableInterface, ResettableInterface{use ProxyTrait;private const METADATA_EXPIRY_OFFSET = 1527506807;private $createCacheItem;private $cacheItemPrototype;public function __construct(CacheItemPoolInterface $pool){
错误原因 PHP版本太低,常量修饰符7.1才支持
PHP 7.1 之前的类常量是不允许添加可见性修饰符的,此时类常量可见性相当于 public。PHP 7.1 为类常量添加了可见性修饰符支持特性。总的来说,可见性修饰符使用范围如下所示:
函数/方法:public、private、protected、abstract、final
- 类:abstract、final
- 属性/变量:public、private、protected
- 类常量:public、private、protected