Cms: Broken IDE auto completion for Craft::$app

Created on 25 Oct 2020  ·  3Comments  ·  Source: craftcms/cms

Description

Since this commit by @angrybrad the phpdoc for Craft::$app has moved into the CraftTrait and is back referenced with @mixin. But Intelephense for VS Code for example doesn't support the @mixin pattern (https://github.com/bmewburn/vscode-intelephense/issues/123), so at least for VS Code auto completion is now broken for Craft::$app 😢

Steps to reproduce

  1. Use VS Code
  2. Try to auto complete Craft::$app->getEle…

Additional info

  • Craft version: 3.5.14
bug

Most helpful comment

Ah interesting, sure we can add that. That trick doesn’t actually work for PhpStorm, but can’t hurt.

All 3 comments

We use the @mixin trick in a few other places as well, and that commit fixed a major testing bug, so I don’t want to revert it. I love VSCode, but it’s not a great PHP editor.

I won't go into an editor discussion, because it's a personal choice.

My quick fix was to add @property \craft\web\Application|\craft\console\Application $app to the phpdoc for Craft. Maybe it's possible to add this? I think that I'm not alone using VS Code developing Craft and it would restore the great developer experience I had with Craft. Thank you ❤️

Ah interesting, sure we can add that. That trick doesn’t actually work for PhpStorm, but can’t hurt.

Was this page helpful?
0 / 5 - 0 ratings