DanVeira DanVeira - 1 year ago 257
PHP Question

Undefined constant Traits in PhpStorm 2016.2.1

I am developing with Laravel 5.3 and everything works fine but PhpStorm keeps squawking at the namespace every time I use "Traits", like this:

Print Screen

Please note that the code works fine, no errors whatsoever so I'm guessing this is a PhpStorm's issue.

Answer Source

This looks like Parser issue -- happens when namespace contains words that are similar to PHP keywords (Traits in your case).

Things you can try:

  • Cutting whole text into clipboard and then pasting it back.
  • If still the same -- try Code | Inspect Code... and run it on this file only.
  • If still nothing -- try restarting IDE.

Other than that -- https://youtrack.jetbrains.com/issue/WI-5015 -- watch this ticket (star/vote/comment) to get notified on proper fix.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download