Undefined class self in included file

Hello,

I have a class that in a function has a quite long HTML part.
I've decided to move this block in a separated file and include it where I need it.

However, this file, to get data from some static method and fields, often makes use of the "self" object (eg.: self::$somefield).

The problem is that PhpStorm inspection keeps saying that self is undefined.

I know how to solve this with variables, using comments like /** @var $myvariable string */, but how can I do the same in this case?

6 comments
Comment actions Permalink

Yeah, this is weird, i never saw PHP is deprecating the keyword self. Does somebody have a link about this?

0
Comment actions Permalink

That's a 3+ years old post and got noticed only now :)

I can't even remember was I was talking about and for sure I manage to live with this issue (provided it didn't get fixed meanwhile).

0
Comment actions Permalink

The issue still exists.

Looks like the only way is to refer to the static variables via getters/setters.

0
Comment actions Permalink

Could you please attach a sample project or just two files that would illustrate the problem clearly? You can submit this at http://youtrack.jetbrains.com/issues/WI#newissue=yes

0
Comment actions Permalink

the solution of this is with the tag

/** @static Class */

on top of the property or

/**
* @static Class property
*/
on top of the class
0

Please sign in to leave a comment.