php类中的私有静态变量

Hai*_*ood 9 php static codeigniter private-members

我有几类,往往是通过运行var_dump或print_r.

在这些类中,我有一些变量,它们是对其他大型对象的引用,每个对象只有一个实例,并且只在类中使用(类外部有自己对这些类的引用)我不希望这些类打印在输出中,所以我声明它们private static工作正常.

但是Member has private access当我访问它时,我的IDE(PHPstorm)会弹出一个错误级别的警报self::$ci->...

我想知道这是否是IDE中的一个错误,突出显示因为它可能是一个错误(也就是它是静态的,但是类之外没有任何东西可以访问它,你为什么要这样做?),或者因为实际上存在语法上的错误用它?

作为示例,这里是类的一部分,注意,它=& get_instance();返回对Code Igniter超级对象的引用

private static $ci = null;

public function __construct(){
    self::$ci = self::$ci =& get_instance();
}

public function product() {
    if ($this->product == null) {
        self::$ci->products->around($this->relative_date);
        $this->product = self::$ci->products->get($this->product_id);
    }
    return $this->product;
}
Run Code Online (Sandbox Code Playgroud)

Pie*_*scy 5

在您的product()方法中,您尝试访问 private member self::$ci。您的 IDE 认为该方法可以在任何地方访问,并检测到与私有静态成员冲突$ci。