[deprecation] Deprecate AddParamArrayDocblockBasedOnArrayMapRector - #8340
Merged
Conversation
TomasVotruba
force-pushed
the
deprecate-param-array-docblock-array-map
branch
from
August 10, 2026 19:21
c42ed46 to
a29bd5e
Compare
TomasVotruba
enabled auto-merge (squash)
August 10, 2026 19:22
…s a single array_map() call is a vague type source The rule reads the closure param type of one array_map() call inside the body and turns it into a @PARAM docblock for the whole parameter. One call site does not prove what every caller passes, so the added type is often too narrow. Add the docblock manually instead.
TomasVotruba
force-pushed
the
deprecate-param-array-docblock-array-map
branch
from
August 10, 2026 19:24
a29bd5e to
12eb975
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The rule looks for one
array_map()call inside a method body, reads the param type of its closure, and writes that as a@paramdocblock for the whole parameter.One call site is not evidence about the parameter. The closure only tells us what that single
array_map()reads; callers may pass anything else the nativearraytype allows.final class SomeClass { + /** + * @param string[] $names + */ public function run(array $names): void { $names = array_map(fn(string $name) => trim($name), $names); } }If any caller passes
Name[], or the closure param type is itself just a guess, the docblock is wrong - and PHPStan trusts it over the nativearray.Add the docblock manually, or write a custom rule that knows the project's call sites.
Changes:
DeprecatedInterfaceand throws onrefactor()TypeDeclarationDocblocksLevelsetArrayMapClosureExprFinderremoved, it had no other user