镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

[type-declaration-docblocks] Add AddParamArrayDocblockFromDimFetchAccessRector - #7253

Merged
TomasVotruba merged 1 commit into
mainfrom
tv-add-param-based-on-array-dim-fetch-access
Sep 12, 2025
Merged

TomasVotruba merged 1 commit into
mainfrom
tv-add-param-based-on-array-dim-fetch-access

Conversation

@TomasVotruba

@TomasVotruba TomasVotruba commented Sep 12, 2025 •

Copy link
Copy Markdown
Member

This rules adds known @param docblock for keys used in method body 👍

 final class ParamArray
 { 
+    /**
+     * @param array<string, mixed> $data
+     */
     public function process(array $data): void
     {
         $item = $data['key'];

         $anotherItem = $data['another_key'];
     }
 }

@TomasVotruba
TomasVotruba force-pushed the tv-add-param-based-on-array-dim-fetch-access branch from e8f7f30 to 2a1295a Compare September 12, 2025 12:00
@TomasVotruba
TomasVotruba enabled auto-merge (squash) September 12, 2025 12:00
@TomasVotruba
TomasVotruba merged commit 01a21ae into main Sep 12, 2025
49 checks passed
@TomasVotruba
TomasVotruba deleted the tv-add-param-based-on-array-dim-fetch-access branch September 12, 2025 12:01
@samsonasik

samsonasik commented Sep 12, 2025 •

Copy link
Copy Markdown
Member

It seems mostly got mixed value, which may be int or string, eg:

function foo(array $params, int $page, int $limit)
{
   $params['page'] = $page;
   $params['limit'] = $limit;
}

got:

+/**
+ * @param array<string, mixed> $params
+ */

which I think should possibly:

+/**
+ * @param array<string, int> $params
+ */

@TomasVotruba

TomasVotruba commented Sep 12, 2025 •

Copy link
Copy Markdown
Member Author

That doesn't have to be true, as $params can contains even string and other values.

@TomasVotruba

Copy link
Copy Markdown
Member Author

Do you have some real-world file where this rule should be improved? More context would help

@samsonasik

Copy link
Copy Markdown
Member

Yes, on our project 👍 , using blindly set to mixed will cause everything like mixed, while it on use is not.

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been automatically locked because it has been closed for 150 days. Please open a new PR if you want to continue the work.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Feb 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants