Repository navigation
Conversation
GromNaN
left a comment
There was a problem hiding this comment.
The PHPStan errors on groupBy and addGroupBy only are incorrect. The function validateVariadicParameter return void, not a bool.
Declare the parameter as list<mixed> instead of asserting it. Add @no-named-arguments to the methods that rely on the runtime validation, so that static analysis knows their variadic parameter is a list.
7bb66a8 to
7bd3965
Compare
|
I rebased on 3.8.x and pushed a follow-up commit to fix the PHPStan failure. The error was I first considered ignoring it or changing the helper to
This removes the error without any ignore or baseline entry, and PHPStan now reports a missing The runtime check still works because the project sets |
| /** | ||
| * @param TItem[] $parameter | ||
| * | ||
| * @template TItem | ||
| * @phpstan-assert list<TItem> $parameter | ||
| */ |
There was a problem hiding this comment.
We might have to revert this change once phpstan/phpstan-src#6824 is released.
There was a problem hiding this comment.
Maybe yes, or maybe not: I think it might have been written that way because at the time, we did not set treatPhpdocAsCertain to false.
|
Thanks @savinmikhail ! |
|
@greg0ire happy to help! I found these cases while working on AddNamedArgumentsRector, a rule I maintain that converts positional arguments to named arguments and respects @no-named-arguments. Applying it to the test suite and running the tests might uncover more cases like these than I found. Could be useful as a one-off experiment, even without adopting the rule in the project. |
Add
@no-named-argumentsto the variadicQueryBuilderhelpers used for projections and grouping:select()addSelect()groupBy()addGroupBy()Why this is separate from #12512
I split this out from the
where()/having()condition helpers on purpose.The first PR focused on the most obvious condition-building methods, where named arguments are especially misleading for the variadic predicate-style API and where there is already a related bug signal in #11253.
This PR covers a second group of variadic helpers where the main concern is API contract clarity and tooling guidance: the parameter names are still implementation details rather than something that should be treated as a stable named-argument contract.
Related
Validation
vendor/bin/phpunit tests/Tests/ORM/QueryBuilderTest.phpvendor/bin/phpcs --standard=phpcs.xml.dist src/QueryBuilder.php