Skip to content

Commit dcde9e9

Browse files
Merge branch '4.4' into 5.0
* 4.4: [Validator] fix access to uninitialized property when getting value [HttpClient] Fix regex bearer [Translator] Default value for 'sort' option in translation:update should be 'asc' [HttpKernel] Fix stale-if-error behavior, add tests [Intl] Provide more locale translations [Mailer] Fix STARTTLS support for Postmark and Mandrill [Messenger] Check for all serialization exceptions during message dec… [Messenger] Fix bug when using single route with XML config Fix exception message in Doctrine Messenger [DI] CheckTypeDeclarationsPass now checks if value is type of parameter type [SecurityBundle] fix security.authentication.provider.ldap_bind arguments Improved error message when no supported user provider is found Mysqli doesn't support the named parameters used by PdoAdapter Added debug argument to decide if debug page should be shown or not Mysqli doesn't support the named parameters used by PdoStore Properly handle phpunit arguments for configuration file [Mailer] add tests for http transports
2 parents bad9814 + eb3e15d commit dcde9e9

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

Mapping/PropertyMetadata.php

+7-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,13 @@ public function __construct(string $class, string $name)
4848
*/
4949
public function getPropertyValue($object)
5050
{
51-
return $this->getReflectionMember($object)->getValue($object);
51+
$reflProperty = $this->getReflectionMember($object);
52+
53+
if (\PHP_VERSION_ID >= 70400 && !$reflProperty->isInitialized($object)) {
54+
return null;
55+
}
56+
57+
return $reflProperty->getValue($object);
5258
}
5359

5460
/**

Tests/Fixtures/Entity_74.php

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
namespace Symfony\Component\Validator\Tests\Fixtures;
4+
5+
class Entity_74
6+
{
7+
public int $uninitialized;
8+
}

Tests/Mapping/PropertyMetadataTest.php

+13
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@
1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Validator\Mapping\PropertyMetadata;
1616
use Symfony\Component\Validator\Tests\Fixtures\Entity;
17+
use Symfony\Component\Validator\Tests\Fixtures\Entity_74;
1718

1819
class PropertyMetadataTest extends TestCase
1920
{
2021
const CLASSNAME = 'Symfony\Component\Validator\Tests\Fixtures\Entity';
22+
const CLASSNAME_74 = 'Symfony\Component\Validator\Tests\Fixtures\Entity_74';
2123
const PARENTCLASS = 'Symfony\Component\Validator\Tests\Fixtures\EntityParent';
2224

2325
public function testInvalidPropertyName()
@@ -53,4 +55,15 @@ public function testGetPropertyValueFromRemovedProperty()
5355
$this->expectException('Symfony\Component\Validator\Exception\ValidatorException');
5456
$metadata->getPropertyValue($entity);
5557
}
58+
59+
/**
60+
* @requires PHP 7.4
61+
*/
62+
public function testGetPropertyValueFromUninitializedProperty()
63+
{
64+
$entity = new Entity_74();
65+
$metadata = new PropertyMetadata(self::CLASSNAME_74, 'uninitialized');
66+
67+
$this->assertNull($metadata->getPropertyValue($entity));
68+
}
5669
}

0 commit comments

Comments
 (0)