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

[DoctrineBridge][DoctrineExtractor] Fix wrong guessed type for "json" type #35987

Merged
merged 1 commit into from Mar 13, 2020

Conversation

fancyweb
Copy link
Contributor

@fancyweb fancyweb commented Mar 6, 2020

Q A
Branch? 3.4
Bug fix? yes
New feature? no
Deprecations? no
Tickets #35968
License MIT
Doc PR -

After checking the code, it appears that json have a different behavior than json_array.

In json_array doctrine was converting null or empty value to array, but json type doesn't do that

@norkunas is right about this. Consequently, we cannot safely guess a built in type for the json Doctrine type.

@@ -266,7 +265,6 @@ private function getPhpType($doctrineType)
case self::$useDeprecatedConstants ? DBALType::TARRAY : 'array':
case self::$useDeprecatedConstants ? DBALType::SIMPLE_ARRAY : Types::SIMPLE_ARRAY:
case 'json_array':
case self::$useDeprecatedConstants ? false : Types::JSON:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can keep the case to show we handle it but return null intentionally?

@xabbuh xabbuh added this to the 3.4 milestone Mar 6, 2020
@dunglas
Copy link
Member

dunglas commented Mar 6, 2020

JSON can only be null|string|number|array|\stdClass in PHP (classes and interfaces aren't supported). Maybe it is worth it to return this union type instead of nothing?

@fancyweb
Copy link
Contributor Author

@dunglas That would be null|string|int|float|array|object considering the existing built in types in the PropertyInfo Type class. That would still fix the bug however and seems more consistent. Is that alright for you?

@fancyweb
Copy link
Contributor Author

@nicolas-grekas Does your approval mean you prefer to return nothing?

@nicolas-grekas
Copy link
Member

Does your approval mean you prefer to return nothing?

yes :)

@nicolas-grekas
Copy link
Member

Thank you @fancyweb.

@nicolas-grekas nicolas-grekas merged commit f020876 into symfony:3.4 Mar 13, 2020
@fancyweb fancyweb deleted the doctrine-bridge-json-type branch March 13, 2020 07:57
This was referenced Mar 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants