Skip to content

[AddArrayReturnDocTypeRector] Allow mixed[] and iterable<mixed> in place of Rector's setting wrong infered types#2630

Merged
TomasVotruba merged 7 commits intorectorphp:masterfrom
gnutix:AddArrayReturnDocTypeRector/fix-iterable-mixed
Jan 18, 2020
Merged

[AddArrayReturnDocTypeRector] Allow mixed[] and iterable<mixed> in place of Rector's setting wrong infered types#2630
TomasVotruba merged 7 commits intorectorphp:masterfrom
gnutix:AddArrayReturnDocTypeRector/fix-iterable-mixed

Conversation

@gnutix
Copy link
Copy Markdown
Contributor

@gnutix gnutix commented Jan 10, 2020

Without this fix, it changes the return phpdoc into stuff like @return int[][]|int[][][]|mixed[], which is a mess to read and is plain wrong (a correct one could be @return array<int|int[]> or array<int|array<int>> or int[]|int[][] (though I don't like that multiple [] syntax, hard to read IMO).

@gnutix gnutix requested a review from TomasVotruba January 10, 2020 15:22
@gnutix gnutix removed the request for review from TomasVotruba January 10, 2020 15:46
@gnutix gnutix changed the title Fix AddArrayReturnDocTypeRector on @return iterable<mixed>. Fix AddArrayReturnDocTypeRector (iterable<mixed>, mixed[]) Jan 10, 2020
@gnutix gnutix requested a review from TomasVotruba January 10, 2020 16:06
@gnutix gnutix requested a review from TomasVotruba January 10, 2020 21:17
@gnutix gnutix added the bug label Jan 10, 2020
@gnutix gnutix changed the title Fix AddArrayReturnDocTypeRector (iterable<mixed>, mixed[]) [AddArrayReturnDocTypeRector] Allow mixed[] and iterable<mixed> in place of Rector's setting wrong infered types Jan 10, 2020
@gnutix
Copy link
Copy Markdown
Contributor Author

gnutix commented Jan 14, 2020

Do you need anything else to merge this PR ? IMHO, it's ready.

@TomasVotruba
Copy link
Copy Markdown
Member

This is hard to review.

It seems there are 2 mixed changes, skipping iterable and skipping mixed.
First one is ok, the next one would better to discuss and solve separately.

@gnutix
Copy link
Copy Markdown
Contributor Author

gnutix commented Jan 14, 2020

It touches exactly the same condition, so I did them both at once indeed. Would be a pain for me to separate them in two PRs. They are essentially the same things : allowing mixed for an array (mixed[]) and for an iterable (iterable<mixed>).

I made the fixtures more explicit. Should be easier to read the diff.

@TomasVotruba
Copy link
Copy Markdown
Member

I made the fixtures more explicit. Should be easier to read the diff.

I just got into this. It it easier to read, thanks 👍

@TomasVotruba TomasVotruba merged commit 35cbc9f into rectorphp:master Jan 18, 2020
@TomasVotruba TomasVotruba deleted the AddArrayReturnDocTypeRector/fix-iterable-mixed branch January 18, 2020 17:42
TomasVotruba added a commit that referenced this pull request Jul 4, 2022
rectorphp/rector-src@9ab8ce0 [Core] Return early NodeTraverser::STOP_TRAVERSAL on referenced  is true on ParamAnalyzer (#2630)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants