2

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.

LazyOne
  • 158,824
  • 45
  • 388
  • 391
DanVeira
  • 361
  • 1
  • 6
  • 15
  • Have you tried using `barryvdh/laravel-ide-helper`? It helps IDEs keep track of namespaces and functions. You can also try running `composer dumpautoload` – aynber Nov 07 '16 at 14:32
  • Yes -- this looks like Parser issues when namespace contains words that are similar to PHP keywords (`Trait`s in your case). See https://youtrack.jetbrains.com/issue/WI-5015 . Try cutting whole text into clipboard and then pasting it back -- does it help. if not -- try `Code | Analyze` for this file only. If still nothing -- try restarting IDE. – LazyOne Nov 07 '16 at 14:34
  • Hello @aynber and @LazyOne. Yes, I am using `barryvdh/laravel-ide-helper` and I've tried `composer dump-autoload`. – DanVeira Nov 07 '16 at 14:34
  • @LazyOne Cutting the whole text and pasting in back worked! I had tried restarting the IDE but this was the solution. Thank you! – DanVeira Nov 07 '16 at 14:37
  • I fixed it with File > Invalidate Caches / Restart – Yoann Kergall Oct 27 '18 at 11:32

1 Answers1

3

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.

LazyOne
  • 158,824
  • 45
  • 388
  • 391