Skip to content

[Serializer][PropertyInfo] Fix support for "false" built-in type on PHP 8.2 #45981

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

Merged

Conversation

alexandre-daubois
Copy link
Member

@alexandre-daubois alexandre-daubois commented Apr 8, 2022

Q A
Branch? 4.4
Bug fix? yes (new language feature support)
New feature? no
Deprecations? no
Tickets NA
License MIT
Doc PR NA

false and null built-in types have been merged in PHP 8.2 a few hours ago: php/php-src#7546 🎉
RFC: https://wiki.php.net/rfc/null-false-standalone-types

PropertyInfo and Serializer both need an update to support them.

@carsonbot carsonbot added this to the 4.4 milestone Apr 8, 2022
@carsonbot carsonbot changed the title [Serializer][PropertyInfo] Add support of false built-in type (from PHP 8.2) [PropertyInfo][Serializer] Add support of false built-in type (from PHP 8.2) Apr 8, 2022
@alexandre-daubois alexandre-daubois changed the title [PropertyInfo][Serializer] Add support of false built-in type (from PHP 8.2) [PropertyInfo][Serializer] Add support of false built-in type (available from PHP 8.2) Apr 8, 2022
@alexandre-daubois alexandre-daubois force-pushed the fix-false-builtin-type branch 2 times, most recently from 9512543 to d915fe4 Compare April 9, 2022 13:25
@michaljusiega
Copy link
Contributor

Thanks for PR. Can we wait for https://wiki.php.net/rfc/true-type RFC also?

@alexandre-daubois
Copy link
Member Author

I planned to do it as soon as it is merged if this PR is merged before "true" is available, but yeah I can definitely embed it as well in this pull request 👍

Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

Works for me, with minor comments, thanks.
(true should wait until the RFC is approved)

@chalasr
Copy link
Member

chalasr commented Apr 27, 2022

@alexandre-daubois Can you update the PropertyInfo's conflict rule + dev requirement for symfony/serializer so that it only allows serializer v4.4.42 or higher? That should fix the low-deps build

@alexandre-daubois
Copy link
Member Author

I'll take a look into that as soon as possible!

@alexandre-daubois alexandre-daubois force-pushed the fix-false-builtin-type branch 2 times, most recently from f074bda to 1e4f810 Compare May 9, 2022 18:36
@chalasr
Copy link
Member

chalasr commented May 9, 2022

Wait, it's the opposite actually 🤦‍♂️ Serializer needs symfony/property-info >=4.4.1. Sorry for the bad hint!

@alexandre-daubois alexandre-daubois force-pushed the fix-false-builtin-type branch from 1e4f810 to bfb1146 Compare May 10, 2022 06:59
@alexandre-daubois
Copy link
Member Author

Right, makes more sense 😄 At least, I figured out what are high-deps/low-deps builds. Thank you Robin!

@nicolas-grekas nicolas-grekas changed the title [PropertyInfo][Serializer] Add support of false built-in type (available from PHP 8.2) [Serializer][PropertyInfo] Fix support for "false" built-in type on PHP 8.2 May 10, 2022
@nicolas-grekas nicolas-grekas force-pushed the fix-false-builtin-type branch from bfb1146 to 0a32f04 Compare May 10, 2022 07:48
@@ -483,7 +483,7 @@ private function validateAndDenormalize(string $currentClass, string $attribute,
return (float) $data;
}

if (('is_'.$builtinType)($data)) {
if ('false' === $builtinType || ('is_'.$builtinType)($data)) {
Copy link
Member

Choose a reason for hiding this comment

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

I've inlined the value of the constant: the minimum version bump is not worth it IMHO.

Copy link
Member Author

Choose a reason for hiding this comment

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

Alright, will do it as well for php/php-src#8326 when it's accepted. Thanks 👍

/**
* @requires PHP 8.2
*/
public function testFalseBuiltInTypes()
Copy link
Member

Choose a reason for hiding this comment

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

This test case was triggering a warning: This test did not perform any assertions

I fixed it.

@nicolas-grekas
Copy link
Member

Thank you @alexandre-daubois.

@nicolas-grekas nicolas-grekas force-pushed the fix-false-builtin-type branch from 0a32f04 to 4187d3f Compare May 10, 2022 07:55
@nicolas-grekas nicolas-grekas merged commit fef98bb into symfony:4.4 May 10, 2022
@nicolas-grekas
Copy link
Member

Looks like something very close was already merge in 5.3 in #45154, so I backported the patch on 4.4 in d7ffaf5, on top of this one.

@fabpot fabpot mentioned this pull request May 14, 2022
This was referenced May 27, 2022
nicolas-grekas added a commit that referenced this pull request Jun 20, 2022
…HP 8.2) (bobahvas, alexandre-daubois)

This PR was merged into the 6.2 branch.

Discussion
----------

[Serializer] Add support of true built-in type (from PHP 8.2)

| Q             | A
| ------------- | ---
| Branch?       | 6.2
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

RFC: https://wiki.php.net/rfc/true-type
Pull request: php/php-src#8326

Same as this PR to add support of `false` and `null` types: #45981

Commits
-------

2ec0453 [Serializer] Add support of true built-in type (from PHP 8.2)
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.

6 participants