-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\PropertyInfo\Tests\Fixtures; | ||
|
||
class Php82Dummy | ||
{ | ||
public null $nil = null; | ||
|
||
public false $false = false; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -483,7 +483,7 @@ private function validateAndDenormalize(string $currentClass, string $attribute, | |
return (float) $data; | ||
} | ||
|
||
if (('is_'.$builtinType)($data)) { | ||
if ('false' === $builtinType || ('is_'.$builtinType)($data)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 👍 |
||
return $data; | ||
} | ||
} catch (NotNormalizableValueException $e) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Serializer\Tests\Fixtures; | ||
nicolas-grekas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
class FalseBuiltInDummy | ||
{ | ||
public false $false = false; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,7 @@ | |
use Symfony\Component\Serializer\Tests\Fixtures\DummyMessageInterface; | ||
use Symfony\Component\Serializer\Tests\Fixtures\DummyMessageNumberOne; | ||
use Symfony\Component\Serializer\Tests\Fixtures\DummyMessageNumberTwo; | ||
use Symfony\Component\Serializer\Tests\Fixtures\FalseBuiltInDummy; | ||
use Symfony\Component\Serializer\Tests\Fixtures\NormalizableTraversableDummy; | ||
use Symfony\Component\Serializer\Tests\Fixtures\TraversableDummy; | ||
use Symfony\Component\Serializer\Tests\Normalizer\TestDenormalizer; | ||
|
@@ -572,6 +573,19 @@ public function testUnionTypeDeserializable() | |
$this->assertEquals(new DummyUnionType(), $actual, 'Union type denormalization third case failed.'); | ||
} | ||
|
||
/** | ||
* @requires PHP 8.2 | ||
*/ | ||
public function testFalseBuiltInTypes() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test case was triggering a warning: I fixed it. |
||
{ | ||
$extractor = new PropertyInfoExtractor([], [new ReflectionExtractor()]); | ||
$serializer = new Serializer([new ObjectNormalizer(null, null, null, $extractor)], ['json' => new JsonEncoder()]); | ||
|
||
$actual = $serializer->deserialize('{"false":false}', FalseBuiltInDummy::class, 'json'); | ||
|
||
$this->assertEquals(new FalseBuiltInDummy(), $actual); | ||
} | ||
|
||
private function serializerWithClassDiscriminator() | ||
{ | ||
$classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader())); | ||
|
Uh oh!
There was an error while loading. Please reload this page.