Merge branch '5.2' into 5.x
* 5.2: [Uid] Fix time to float conversion [Serializer] Prevent access to private properties without getters
This commit is contained in:
commit
e2e2640d5a
@ -111,8 +111,9 @@ class ObjectNormalizer extends AbstractObjectNormalizer
|
|||||||
|
|
||||||
// properties
|
// properties
|
||||||
foreach ($reflClass->getProperties() as $reflProperty) {
|
foreach ($reflClass->getProperties() as $reflProperty) {
|
||||||
|
$isPublic = $reflProperty->isPublic();
|
||||||
|
|
||||||
if ($checkPropertyInitialization) {
|
if ($checkPropertyInitialization) {
|
||||||
$isPublic = $reflProperty->isPublic();
|
|
||||||
if (!$isPublic) {
|
if (!$isPublic) {
|
||||||
$reflProperty->setAccessible(true);
|
$reflProperty->setAccessible(true);
|
||||||
}
|
}
|
||||||
@ -120,9 +121,10 @@ class ObjectNormalizer extends AbstractObjectNormalizer
|
|||||||
unset($attributes[$reflProperty->name]);
|
unset($attributes[$reflProperty->name]);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!$isPublic) {
|
}
|
||||||
continue;
|
|
||||||
}
|
if (!$isPublic) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($reflProperty->isStatic() || !$this->isAllowedAttribute($object, $reflProperty->name, $format, $context)) {
|
if ($reflProperty->isStatic() || !$this->isAllowedAttribute($object, $reflProperty->name, $format, $context)) {
|
||||||
|
@ -0,0 +1,23 @@
|
|||||||
|
<?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;
|
||||||
|
|
||||||
|
final class DummyPrivatePropertyWithoutGetter
|
||||||
|
{
|
||||||
|
private $foo = 'foo';
|
||||||
|
private $bar = 'bar';
|
||||||
|
|
||||||
|
public function getBar()
|
||||||
|
{
|
||||||
|
return $this->bar;
|
||||||
|
}
|
||||||
|
}
|
@ -33,6 +33,7 @@ use Symfony\Component\Serializer\Serializer;
|
|||||||
use Symfony\Component\Serializer\SerializerInterface;
|
use Symfony\Component\Serializer\SerializerInterface;
|
||||||
use Symfony\Component\Serializer\Tests\Fixtures\Annotations\GroupDummy;
|
use Symfony\Component\Serializer\Tests\Fixtures\Annotations\GroupDummy;
|
||||||
use Symfony\Component\Serializer\Tests\Fixtures\CircularReferenceDummy;
|
use Symfony\Component\Serializer\Tests\Fixtures\CircularReferenceDummy;
|
||||||
|
use Symfony\Component\Serializer\Tests\Fixtures\DummyPrivatePropertyWithoutGetter;
|
||||||
use Symfony\Component\Serializer\Tests\Fixtures\OtherSerializedNameDummy;
|
use Symfony\Component\Serializer\Tests\Fixtures\OtherSerializedNameDummy;
|
||||||
use Symfony\Component\Serializer\Tests\Fixtures\Php74Dummy;
|
use Symfony\Component\Serializer\Tests\Fixtures\Php74Dummy;
|
||||||
use Symfony\Component\Serializer\Tests\Fixtures\Php74DummyPrivate;
|
use Symfony\Component\Serializer\Tests\Fixtures\Php74DummyPrivate;
|
||||||
@ -140,6 +141,15 @@ class ObjectNormalizerTest extends TestCase
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testNormalizeObjectWithPrivatePropertyWithoutGetter()
|
||||||
|
{
|
||||||
|
$obj = new DummyPrivatePropertyWithoutGetter();
|
||||||
|
$this->assertEquals(
|
||||||
|
['bar' => 'bar'],
|
||||||
|
$this->normalizer->normalize($obj, 'any')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public function testDenormalize()
|
public function testDenormalize()
|
||||||
{
|
{
|
||||||
$obj = $this->normalizer->denormalize(
|
$obj = $this->normalizer->denormalize(
|
||||||
|
@ -124,7 +124,7 @@ class BinaryUtil
|
|||||||
$time = self::add($time, self::TIME_OFFSET_COM2);
|
$time = self::add($time, self::TIME_OFFSET_COM2);
|
||||||
|
|
||||||
if ($time >= self::TIME_OFFSET_COM2) {
|
if ($time >= self::TIME_OFFSET_COM2) {
|
||||||
$time = -1 * self::toBase($time ^ "\xff\xff\xff\xff\xff\xff\xff\xff", self::BASE10);
|
$time = -1 * (self::toBase($time ^ "\xff\xff\xff\xff\xff\xff\xff\xff", self::BASE10) + 1);
|
||||||
} else {
|
} else {
|
||||||
$time[0] = $time[0] & "\x7F";
|
$time[0] = $time[0] & "\x7F";
|
||||||
$time = self::toBase($time, self::BASE10);
|
$time = self::toBase($time, self::BASE10);
|
||||||
|
@ -307,4 +307,13 @@ class UuidTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->assertInstanceOf(CustomUuid::class, CustomUuid::fromString(self::A_UUID_V4));
|
$this->assertInstanceOf(CustomUuid::class, CustomUuid::fromString(self::A_UUID_V4));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testGetTime()
|
||||||
|
{
|
||||||
|
$this->assertSame(103072857660.6847, ((new UuidV1('ffffffff-ffff-1fff-a456-426655440000'))->getTime()));
|
||||||
|
$this->assertSame(0.0000001, ((new UuidV1('13814001-1dd2-11b2-a456-426655440000'))->getTime()));
|
||||||
|
$this->assertSame(0.0, (new UuidV1('13814000-1dd2-11b2-a456-426655440000'))->getTime());
|
||||||
|
$this->assertSame(-0.0000001, (new UuidV1('13813fff-1dd2-11b2-a456-426655440000'))->getTime());
|
||||||
|
$this->assertSame(-12219292800.0, ((new UuidV1('00000000-0000-1000-a456-426655440000'))->getTime()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user