Support custom variables in the html files
I`m writing a plugin to support MVC pattern.
In the controller, I have following code (prototype)
```php
function handle(Request $r) : Response
return $this->view('test/index.html', ['user'=>'funivan']);
}
```
And html file `test/index.html`
```
<h1>Hello $user</h1>
```
I already write completion and type resolving for the variables passed to the view files. For example when i write `$<cursror>` andt hit `Ctrl+Space` phpstorm suggest variables that can be used in this view.
The only thing that I cannot fix is `Undefined variable inspection`.
Is there any way to give the knowledge about the variable to the inspection? When I enable inspection in the view files scope - I get `Undefined variable` warning.
请先登录再写评论。
Hello.
It seems I will need more information from you, since by default $user inside html won't be parsed into php variable and there can't be such warning.
Could you please share the way, how you, for example, provided type resolving for the variable? Or maybe your plugin open-sourced? So I will know what PSI can be there.
I`m using PhpTypeProvider3 to recognize types in the PhpStorm. Also, I have implemented GotoDeclarationHandler and VariableCompletionContributor
Here is the full source code https://gist.github.com/funivan/5b9fe0a55190df86402dc03386df2443 for the type resolving.
Could you please provide sources of implemented GotoDeclarationHandler as well?
https://gist.github.com/funivan/5b9fe0a55190df86402dc03386df2443 Add 3 classes:
UPD: link fixed
Unfortunately I still can't figure out why you has such error based on code you provided. Is there any chance that you can share the whole plugin with us so I can debug it and spot the problem? It can be done via email kirill.smelov@jetbrains.com or github profile https://github.com/wbars if it's private.
Hm. I have clean the index and after reindexing, all seems to works fine. Type resolved correctly and works like a charm. No "undefined variable" errors.