-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for custom models file #139
Comments
Hey @brendt ! I'm sorry but I don't really work with Laravel much anymore at the dayjob, so I don't have much incentive to dig into this. I can say that I really wanted the ability for this plugin to not rely on ide-helper. I think an option to not generate ide-helper stuff would be great. Would be very happy to merge a PR doing this! |
Awesome, can you point me to a guide or something that explains best practices for psalm plugin development? |
@brendt Can you please elaborate:
Thank you! 🙏 |
I'll throw in another reason why using a pre-generated helper file would be useful: I am using Laravel Sail for my local development environment, so there is no direct access to the database unless I would explicitly forward the specific Docker container. When I initially tried to use this plugin in a Sail project, I was wondering why Psalm did not seem to get any kind of model stubs whatsoever and the Running Psalm inside Sail works ( #!/bin/sh
SAIL="./vendor/bin/sail"
"${SAIL}" artisan ide-helper:generate -n
"${SAIL}" artisan ide-helper:models -n -M
# ... other helper generators if applicable, e.g. Lighthouse This allows me to quickly regenerate any helpers whenever I knowingly changed some models and my IDE picks them automatically up. With the current behavior of this plugin I would also either have to:
If specifying a pre-generated helper file was possible, this plugin would simply use the same helper that my IDE uses and I would not have to worry about inconsistent helpers or providing database access while running Psalm on the host. |
PRs welcome! |
@caugner the issue is from a while back, so I don't remember any more details than the ones provided here. It doesn't really matter to me though: all these problems would be solved if I could manually specify a pregenerated ide helper file. I think @ppmathis came up with another good use case. Like I said I'm able to contribute some time to PR this, but I'd like some pointers to where to start, maybe an high-level explanation of how psalm currently generates IDE helper data, etc. |
I believe we would need 2 configuration options -- one for the path to the models file and one for the path to the facades file. The symfony plugin supports config options, so we could likely use them to model our implementation https://github.com/psalm/psalm-plugin-symfony#configuration https://github.com/psalm/psalm-plugin-symfony/blob/master/src/Plugin.php#L87-L94 The files are generated / supplied to the plugin via a simple |
I'm not sure why, but with certain versions of this plugins things stop working. Especially when it comes to model properties not being found.
I would like to suggest a feature where you can instruct psalm to use the existing models files, instead of generating a new one on the fly.
I had a look at
\Psalm\LaravelPlugin\Plugin::ingestModelStubs
and thing the feature wouldn't be that difficult to implement. In my mind it would look something like this:self::$model_classes
to contain the correct value — still need to figure that one out, but that shouldn't be any rocket science.I want to PR this myself but I'll need some pointers on what the right approach is here. Would love your input.
The text was updated successfully, but these errors were encountered: