eclipseeclipse-pdt

Eclipse PDT Variable $this is undefined


Sorry if this have been asked before. I have searched but not found any answers.

I installed Eclipse Photon (4.8.0) for PHP developers and created a project from existing folder.

I noticed that when I opened index.php that variable $this is undefined:

variable $this is undefined

This happens everywhere in my project. Also in the .phtml (view) files.

variable $this is undefined

I am quite new to Eclipse and I couldn't find anything in the settings.

Does anyone know how to remove the warning and fix this?

Thank you!


Solution

  • I found this post on the Eclipse forum, which worked for me. Instead of disabling the undefined variables, I just had to add:

    /** @var Type $this */
    

    to my file and it no longer shows up as a warning. After review of a project in update PDT and PHP version, I had to change it to:

    /** @var mixed $this */