-
Notifications
You must be signed in to change notification settings - Fork 824
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
Docblock comments on DataList shadow SS_List's more useful PHPDoc types in PHPStorm (::first, ::byID, ::find, ::filter, etc.) #11247
Comments
Closing because this is an issue with PHPStorm, not with Silverstripe The type hinting works correctly in VSCode, at least with the PHP Intelephense plugin - with the example above I was correctly type hinted for a Member. Type hinting was greatly improved in 5.2 with generic type hints |
@emteknetnz I don't understand this stance? I agree that 5.2 is a huge improvement, and was running my own stubs with generic type hints before 5.2. But the reason for adding the generic type hints is to improve dev experience, and the current types don't work with PHPStorm's analysis but would work with just the inclusion of Is there something I'm missing about |
Seems like a pretty trivial fix, and given the prevalence of PHPStorm I think it’s worthwhile. Some of the comments in |
Sure. Which branch would you like me to target it on? |
I think |
Targetting 5.2 is fine for this particular enhancement, it's not changing the functional behaviour of any classes. Means you'll get your patch release immediately instead of having to wait several months. |
Linked PR has been merged, it will be automatically tagged shortly |
Module version(s) affected
5.2.1
Description
I'm not sure on the exact behaviour of phpstan, but at least PHPStorm's inbuilt analyser does not correctly type the following snippet:
This is because PHPStorm is ignoring SS_List's typings when a docblock is present on a method in DataList. PHPStorm correctly identifies the type of
$member
if the docblock comments offilter
andfirst
are removed, or if@inheretDoc
is added to both methods' docblocks.How to reproduce
in a fresh install of silverstripe & PHPStorm. PHPStorm doesn't recognise the type of $member and won't provide completion or recognise method calls for refactoring etc.
Possible Solution
Either add
@inheretDoc
to all the offending methods in DataList and its subclasses, or copy the phpdoc types from SS_List into the docblock comments directly.Additional Context
No response
Validations
silverstripe/installer
(with any code examples you've provided)PRs
The text was updated successfully, but these errors were encountered: