claygriffiths global type aliases will be available in the next pre-release.
It will also implement @phpstan-import-type
, which is used a lot i.e. in Symfony.
claygriffiths global type aliases will be available in the next pre-release.
It will also implement @phpstan-import-type
, which is used a lot i.e. in Symfony.
JakubMisek Are there docs on how to use global type aliases with DevSense for VS Code?
I've put a phpstan.neon
(tried phpstan.dist.neon
as well) in a WordPress plugin directory as well as the project root, and it doesn't appear to be loading them.
Thank you!
claygriffiths We don't have docs yet. Most probably we fail to parse the .neon content due to some unexpected whitespace or indentation.
May I ask you to try simplifying the phpstan.neon
file? Maybe the editor will load it then. I guess our reader needs some improvements.
claygriffiths I've found a bug in .neon
file parser - working on it.
JakubMisek Sounds good!
As an example, here's what we have in our phpstan.neon
in one plugin.
parameters:
level: 9
checkGenericClassInNonGenericObjectType: false
paths:
- gs-product-configurator.php
- class-gs-product-configurator.php
- includes/
scanDirectories:
- ../gravityforms
- ../woocommerce
excludePaths:
analyse:
- includes/third-party
ignoreErrors:
# gf_apply_filters only specifies two params.
- '#Function gf_apply_filters invoked with \d+ parameters, 2 required.#'
typeAliases:
GFFeed: '''
array{
id: int,
form_id: int,
meta: array<string, mixed>,
is_active: 0|1,
addon_slug: string,
}
'''
GSPCFeed: '''
GFFeed & array{
meta: array<string, mixed> & array{
display_price: string,
item_meta_display: string,
item_meta_display_template: string,
},
}
'''
claygriffiths thank you, I'll add it into our unit tests!
Preparing pre-release with the updated .neon
parser.
It's working well! Thanks a ton, @JakubMisek.
claygriffiths great! thank you very much for your patience, and all the feedback!
If there will be anything to improve, please feel free to point it out.
Hey @JakubMisek, a quick check-in on this: it has been working great!
So much so that we'd like to start moving our type aliases into a PHPStan extension. While being compatible with https://github.com/phpstan/extension-installer is probably a stretch, it'd be cool if DEVSENSE could support includes
: https://phpstan.org/config-reference#multiple-files
claygriffiths Thank you Clay!
We should support "includes" already (but there might a be a bug of course). Let me check it.
claygriffiths phpstan's includes
should work, I've tested a few sample .neon files so far.
(There is a minor issue with typedefs
not being updated - this will be fixed in the next pre-release - workaround it to reload the vscode window)
May I ask for your phpstan.neon
file(s) so I can check we resolve them correctly?
Thank you!