如何告诉PhpStorm实现细节?(魔术)

如何告诉PhpStorm实现细节?(魔术),phpstorm,Phpstorm,我有一个对象“User”,其属性的可访问性声明为protected,但可以通过magic\uu set-method直接设置 现在PhpStorm用右侧的一个大红色列表示这种明显的不一致性 是否可以向PhpStorm解释发生了什么,从而不再显示为错误 编辑: <?php /** * @property mixed $a */ class c1 { protected $a; public function __construct() { $this->a =

我有一个对象“User”,其属性的可访问性声明为protected,但可以通过magic\uu set-method直接设置

现在PhpStorm用右侧的一个大红色列表示这种明显的不一致性

是否可以向PhpStorm解释发生了什么,从而不再显示为错误


编辑:

<?php
/**
 * @property mixed $a
 */
class c1
{
    protected $a;

    public function __construct() { $this->a = __CLASS__; }

    public function __get($n) { return $this->{$n}; }
}

/**
 * @property $a mixed
 */
class c2
{
    protected $a;

    public function __construct() { $this->a = __CLASS__; }

    public function __get($n) { return $this->{$n}; }
}
string 'c1' (length=2)
string 'c2' (length=2)
我使用PhpStorm 2.1.4

好的,这里有一些代码举例说明了这个问题(以及Alexey到目前为止建议的解决方法,可惜它不适合我):

c.php:

<?php
/**
 * @property mixed $a
 */
class c1
{
    protected $a;

    public function __construct() { $this->a = __CLASS__; }

    public function __get($n) { return $this->{$n}; }
}

/**
 * @property $a mixed
 */
class c2
{
    protected $a;

    public function __construct() { $this->a = __CLASS__; }

    public function __get($n) { return $this->{$n}; }
}
string 'c1' (length=2)
string 'c2' (length=2)
以及它在PhpStorm中的外观:

我的目标:

<?php
/**
 * @property mixed $a
 */
class c1
{
    protected $a;

    public function __construct() { $this->a = __CLASS__; }

    public function __get($n) { return $this->{$n}; }
}

/**
 * @property $a mixed
 */
class c2
{
    protected $a;

    public function __construct() { $this->a = __CLASS__; }

    public function __get($n) { return $this->{$n}; }
}
string 'c1' (length=2)
string 'c2' (length=2)

要么让PhpStorm“理解”设计,要么就是在不影响错误检测的情况下消除所有恼人的红色标记。

这现在在PhpStorm 3中起作用:)

不幸的是,这是跟踪程序中的一个开放请求,请参阅

现在避免此警告的唯一方法是将
@property
添加到$user的类声明中。i、 e

/**
 * @property $name string
 */
class User {
    protected $name; 
}
$user = new User();
$user->name = "me";

解决方案并没有改变PHPStorm将访问解释为错误的情况。我添加了完整的示例。我是IDE中这些检查的开发者。如果它对您不起作用-请转到我们的跟踪器,并提供您的代码进行复制。如果它是一个重载方法,而不是定义为受保护的属性(同名),该怎么办<代码>受保护函数foo($a,$b)和
公共函数调用($m,$p)
如果不更改所有方法的名称,我无法绕过此错误。那么如何告诉IDE在不修改源类注释的情况下隐藏这些检查呢?也就是说,原始类有受保护的方法/字段,但通过一些神奇的转换,这些方法/字段变为公共的,并保证可以工作。如何隐藏这些支票和红色标记?