I’ve figured out how to get the variables like snippet working (my own fault by marking the directory as excluded), however $kirby is still undefined; this is the error i get from phpstorm.
This warning sounds sensible. Using a variable only defined in a if/else block can result in bugs.
But if this inspection in PhpStorm is not useful for you, you can disable it. There are a few inspections I tend to disable because they’re not relevant to a project, my coding style, or because they have too many false positives for my taste.
I started to use PHPStorm and Laravel for work, so when I returned to my Kirby projects this holiday, I was missing PHPStorm, and I noticed… PHPStorm has a hard time understanding Kirby.
So I made this IDE-helper-generator, after the Laravel IDE-helper by barryvdh. Hope it’s useful to someone.
Just put it in your project root and run php _ide_helper_generator.php from the command line. Don’t add the generated files to your Kirby, just leave them for PHPStorm to inspect.