Skip to content

Commit

Permalink
Merge branch '4.4' into 5.0
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
nicolas-grekas committed Jan 31, 2020
2 parents bad9814 + eb3e15d commit dcde9e9
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Mapping/PropertyMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,13 @@ public function __construct(string $class, string $name)
*/
public function getPropertyValue($object)
{
return $this->getReflectionMember($object)->getValue($object);
$reflProperty = $this->getReflectionMember($object);

if (\PHP_VERSION_ID >= 70400 && !$reflProperty->isInitialized($object)) {
return null;
}

return $reflProperty->getValue($object);
}

/**
Expand Down
8 changes: 8 additions & 0 deletions Tests/Fixtures/Entity_74.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace Symfony\Component\Validator\Tests\Fixtures;

class Entity_74
{
public int $uninitialized;
}
13 changes: 13 additions & 0 deletions Tests/Mapping/PropertyMetadataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@
use PHPUnit\Framework\TestCase;
use Symfony\Component\Validator\Mapping\PropertyMetadata;
use Symfony\Component\Validator\Tests\Fixtures\Entity;
use Symfony\Component\Validator\Tests\Fixtures\Entity_74;

class PropertyMetadataTest extends TestCase
{
const CLASSNAME = 'Symfony\Component\Validator\Tests\Fixtures\Entity';
const CLASSNAME_74 = 'Symfony\Component\Validator\Tests\Fixtures\Entity_74';
const PARENTCLASS = 'Symfony\Component\Validator\Tests\Fixtures\EntityParent';

public function testInvalidPropertyName()
Expand Down Expand Up @@ -53,4 +55,15 @@ public function testGetPropertyValueFromRemovedProperty()
$this->expectException('Symfony\Component\Validator\Exception\ValidatorException');
$metadata->getPropertyValue($entity);
}

/**
* @requires PHP 7.4
*/
public function testGetPropertyValueFromUninitializedProperty()
{
$entity = new Entity_74();
$metadata = new PropertyMetadata(self::CLASSNAME_74, 'uninitialized');

$this->assertNull($metadata->getPropertyValue($entity));
}
}

0 comments on commit dcde9e9

Please sign in to comment.