Ignore protected access warning on $this

Hi.

I have a PHP file for the class definition and a separate HTML/PHP file for the template. The template file is included inside the class with an ordinary PHP include. Because of this, all $this references inside the template file are valid, but I can't figure out how to tell PHPStorm this. I've tried typehinting in the template file, but it still complains about protected access. I've managed to get around the problem for class properties by adding @property annotations in the class' PHPDoc, but I'm still having problems with methods.

Usually I don't include templates with plain includes, but this is a  special class which must have simple logic, and not a complex templating  engine.

But I think there shoud be an exception if the typehinted variable is $this which would ignore access levels since $this is a special variable. And I don't like those @property annotations because they sould be redundant in this case.

Has anyone else come across this problem? How did you solve it?

2 comments

Hi there,

@property and @method approach works fine here. Not nice indeed -- but works.

But I think there shoud be an exception if the typehinted variable is $this which would ignore access levels since $this is a special variable.

http://youtrack.jetbrains.com/issue/WI-5076

0

Thank you, I'll keep track of that issue and in the meantime add @property and @method annotations to the class.

0

Please sign in to leave a comment.