Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AssertListItem: fix passing incorrect item type to inner validator #23

Merged
merged 4 commits into from
Aug 15, 2023

Conversation

JanTvrdik
Copy link
Member

No description provided.

@JanTvrdik JanTvrdik changed the title AssertListItem: fix passing correct item type to inner validator AssertListItem: fix passing incorrect item type to inner validator Aug 11, 2023
'ShipMonk\InputMapper\Runtime\Optional',
0,
'Countable & Traversable',
];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add testcase with something similar to this? phpstan/phpstan#9198

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what you mean. There is case for union.

        yield [
            'list<int>|list<string>',
            'list',
            0,
            'int|string',
        ];

There is no normalization for unions for now. But it you ask what is the value type of list<int>|list<string>, the answer has to be int|string which is an information loss. To avoid loosing the information, you must never pass union to inferGenericParameter and handle the union on the caller side. But that is not always pratical.

@JanTvrdik JanTvrdik merged commit 1ca8f19 into master Aug 15, 2023
5 checks passed
@JanTvrdik JanTvrdik deleted the fix-assert-item branch August 15, 2023 08:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants