-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[PropertyInfo] treat simple arrays of mixed values as arrays not as lists #62546
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
Conversation
17c1b34 to
a01284b
Compare
a01284b to
8b3d215
Compare
|
Status: Needs work |
8b3d215 to
21cbbb3
Compare
21cbbb3 to
9f14fea
Compare
| ['mixedCollection', [new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, null, null)], null, null], | ||
| ['collection', [new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, [new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_STRING)], new Type(Type::BUILTIN_TYPE_OBJECT, false, 'DateTimeImmutable'))], null, null], | ||
| ['nestedCollection', [new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, [new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_STRING)], new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, [new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_STRING)], new Type(Type::BUILTIN_TYPE_STRING, false)))], null, null], | ||
| ['mixedCollection', [new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, [new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_STRING)], null)], null, null], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mtarld and me talked about the failures during the hackathon. What we would have preferred as the solution is changing only this line to:
| ['mixedCollection', [new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, [new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_STRING)], null)], null, null], | |
| ['mixedCollection', [new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), null)], null, null], |
That would mean not having to do any changes to prepare for the next phpdocumentor/type-resolver release and would also mean to be consistent with the other collection examples.
However, I found no way to distinguish mixed[] and array on released versions of that package meaning that we would have to bump constraint to have consistently passing tests.
Now, we can get the CI green by enforcing that the key type for arrays is int|string which is technically correct but may break existing code that relies on the key being null. I am not sure how we want to proceed here (if we are fine with the current solution, we should probably align the other extractors).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like I found a way to restore the previous (even if not fully correct) behaviour, see #62577 as an alternative (now checking if we can achieve the same for 7.3+ when we use the TypeInfo component under the hood)
This fixes the PropertyInfo component tests by treating `mixed[]` as an alias of `array` sticking with the current behaviour even if that may technically not be fully correct to avoid unwanted behaviour changes for existing applications (see symfony#62546 (comment)).
This fixes the PropertyInfo component tests by treating `mixed[]` as an alias of `array` sticking with the current behaviour even if that may technically not be fully correct to avoid unwanted behaviour changes for existing applications (see symfony#62546 (comment)).
…tting types from docblocks (xabbuh) This PR was merged into the 6.4 branch. Discussion ---------- [PropertyInfo] treat `mixed[]` the same as `array` when getting types from docblocks | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | account for phpDocumentor/TypeResolver#237 | License | MIT This fixes the PropertyInfo component tests by treating `mixed[]` as an alias of `array` sticking with the current behaviour even if that may technically not be fully correct to avoid unwanted behaviour changes for existing applications (see #62546 (comment)). Commits ------- 2d94451 treat `mixed[]` the same as `array` when getting types from docblocks
This fixes the PropertyInfo component tests by treating `mixed[]` as an alias of `array` sticking with the current behaviour even if that may technically not be fully correct to avoid unwanted behaviour changes for existing applications (see symfony/symfony#62546 (comment)).
|
closing as #62577 has been merged |
Our test suite is currently failing because of what has been done in phpDocumentor/TypeResolver#237. The changed behaviour reminds me of #62388 look reasonable to me.
We need to decide if we want to bump the conflict (we cannot merge yet then as the latest tagged release is 1.12.0) or if we prefer to kind of implement the require logic for older versions of
phpdocumentor/type-resolverourselves inPhpDocTypeHelper::createType().