-
Notifications
You must be signed in to change notification settings - Fork 68
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
PHPStan configuration #285
Comments
Would definitely be a must have 👍 |
@ondrejmirtes Do you have any advice for handling conditionally defined DSL functions in PHPStan? It's a pretty common scenario for describe/it style test runners and matcher libraries like Hamcrest. |
@ezzatron Hi, you can take advantage of the fact that PHPStan environment should match the environment of your application - including definitions of class aliases, constants, autoloaders and defined functions 😊 So you can use the |
Hello @ezzatron, were you able to find some compatible configuration with Kahlan on this topic ? |
Hi @jails, no, I'm sorry, but I haven't had the time to do much of anything PHP-related lately. From the sounds of it though, the |
How about run phpstan to |
@samsonasik This issue is about creating a shared config for projects that use Kahlan, not about running PHPStan over Kahlan's own codebase. |
It would be nice to have a drop-in config for Kahlan for PHPStan. Currently, when run over a Kahlan project, PHPStan warns about:
$this
keyword used inkahlan-config.php
outside of a class context.Here's my current config for handling the first point:
But there's probably a better way to fix the problem that doesn't involve "ignoring" these errors. If PHPStan can be configured to understand the functions it could actually pick up on real errors when using them. Are the DSL functions dynamically defined? That would explain why PHPStan complains.
PHPStan uses Neon config files which allow you to include a definition from a vendor, which means that if you created a
kahlan/phpstan-kahlan
repo, users could require it, then add something like this to their PHPStan configuration:I just wrote a PHPStan integration for Phony, which is probably more complex than what's needed for Kahlan, but you can check it out here anyway.
The text was updated successfully, but these errors were encountered: