Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to tell PhpStorm about implementation details? (magic methods)
    text
    copied!<p>I have an object "User" that has attributes whose accessability is declared as protected but which can be set directly via a magic __set-method.</p> <p><img src="https://i.stack.imgur.com/6lK8j.jpg" alt="enter image description here"></p> <p>Now PhpStorm signals this apparent inconsistency with a big red column on the right side.</p> <p>Is it possible to explain to PhpStorm what is going on so this is not shown as an error any more?</p> <hr> <p><strong>EDIT :</strong></p> <p>I use PhpStorm 2.1.4</p> <p>okay here is some code that exemplifies the issue (together with the so far suggested workaround from Alexey which sadly doesn't do it for me):</p> <p><strong>c.php:</strong></p> <pre><code>&lt;?php /** * @property mixed $a */ class c1 { protected $a; public function __construct() { $this-&gt;a = __CLASS__; } public function __get($n) { return $this-&gt;{$n}; } } /** * @property $a mixed */ class c2 { protected $a; public function __construct() { $this-&gt;a = __CLASS__; } public function __get($n) { return $this-&gt;{$n}; } } </code></pre> <p><strong>test.php</strong></p> <pre><code>&lt;?php require "c.php"; $c1 = new c1(); var_dump($c1-&gt;a); $c2 = new c2(); var_dump($c2-&gt;a); </code></pre> <p><strong>and the output:</strong></p> <pre><code>string 'c1' (length=2) string 'c2' (length=2) </code></pre> <p>and <strong>how it looks</strong> like in PhpStorm:</p> <p><img src="https://i.stack.imgur.com/CKx6T.jpg" alt="enter image description here"></p> <p><strong>my goal:</strong></p> <p>either having PhpStorm "understand" the design or just getting rid of those annoying red marks everywhere while not impairing the error detection apart from this issue.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload