CodeIgniter4
CodeIgniter4 copied to clipboard
style: Enable `phpdoc_list_type` fixer
Description
Enables phpdoc_list_type
, changing array
phpdocs with implicit keys to list
, e.g. array<string> => list<string>
. Then let phpstan catch incorrect usages.
If approved, don't merge yet so this can be applied in the coding standard repo and minimize updating the overrides here.
Checklist:
- [x] Securely signed commits
- [ ] Component(s) with PHPDoc blocks, only if necessary or adds value
- [ ] Unit testing, with >80% coverage
- [ ] User guide updated
- [x] Conforms to style guide
:wave: Hi, @paulbalandan!
We detected conflicts in your PR against the base branch :speak_no_evil:
You may want to sync :arrows_counterclockwise: your branch with upstream!
Ref: Syncing Your Branch
@paulbalandan Sorry, I've changed to use @property-read
. See #8519.
Can you update coding-standard with that?
phpdoc_list_type
is risky.
https://cs.symfony.com/doc/rules/phpdoc/phpdoc_list_type.html
I'm not sure we should enable this rule by default.
Yes, it is risky by the reasoning behind it.
If we make a phpdoc like Foo[]
, I think we almost always mean the same way when we push to an array, like $a[] = Foo;
, so Foo[]
here would mean a list of Foo
, i.e., array<int, Foo>
. If we mean a string key, we should have indicated it like array<string, Foo>
, right?
If we make a phpdoc like Foo[], I think we almost always mean the same way when we push to an array, like $a[] = Foo;, so Foo[] here would mean a list of Foo, i.e., array<int, Foo>. If we mean a string key, we should have indicated it like array<string, Foo>, right?
I checked all the changes in this PR, and you are right. I agree that most PHP devs think like that.
I agree to enable phpdoc_list_type
.
To be merged once latest coding-standard is out.