Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 95eb341

Browse files
committed
Merge branch '5.1'
* 5.1: [Serializer] Fix variadic support when using type hints [VarDumper] Backport handler lock when using VAR_DUMPER_FORMAT [FrameworkBundle] Remove unused form-resources complex type from XSD file Added missing router config
2 parents 8b3df37 + 5ef1679 commit 95eb341

File tree

5 files changed

+42
-19
lines changed

5 files changed

+42
-19
lines changed

src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@
100100
<xsd:attribute name="https-port" type="xsd:string" />
101101
<xsd:attribute name="strict-requirements" type="xsd:string" />
102102
<xsd:attribute name="utf8" type="xsd:boolean" />
103+
<xsd:attribute name="default-uri" type="xsd:string" />
103104
</xsd:complexType>
104105

105106
<xsd:complexType name="session">
@@ -164,12 +165,6 @@
164165
<xsd:attribute name="json-manifest-path" type="xsd:string" />
165166
</xsd:complexType>
166167

167-
<xsd:complexType name="form-resources">
168-
<xsd:choice minOccurs="1" maxOccurs="unbounded">
169-
<xsd:element name="resource" type="xsd:string" />
170-
</xsd:choice>
171-
</xsd:complexType>
172-
173168
<xsd:complexType name="translator">
174169
<xsd:sequence>
175170
<xsd:element name="fallback" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />

src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -230,13 +230,7 @@ public function __destruct()
230230
--$i;
231231
}
232232

233-
if (isset($_SERVER['VAR_DUMPER_FORMAT'])) {
234-
$html = 'html' === $_SERVER['VAR_DUMPER_FORMAT'];
235-
} else {
236-
$html = !\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) && stripos($h[$i], 'html');
237-
}
238-
239-
if ($html) {
233+
if (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) && stripos($h[$i], 'html')) {
240234
$dumper = new HtmlDumper('php://output', $this->charset);
241235
$dumper->setDisplayOptions(['fileLinkFormat' => $this->fileLinkFormat]);
242236
} else {

src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ private function validateAndDenormalize(string $currentClass, string $attribute,
451451
*/
452452
protected function denormalizeParameter(\ReflectionClass $class, \ReflectionParameter $parameter, string $parameterName, $parameterData, array $context, string $format = null)
453453
{
454-
if (null === $this->propertyTypeExtractor || null === $this->propertyTypeExtractor->getTypes($class->getName(), $parameterName)) {
454+
if ($parameter->isVariadic() || null === $this->propertyTypeExtractor || null === $this->propertyTypeExtractor->getTypes($class->getName(), $parameterName)) {
455455
return parent::denormalizeParameter($class, $parameter, $parameterName, $parameterData, $context, $format);
456456
}
457457

src/Symfony/Component/Serializer/Tests/Fixtures/VariadicConstructorTypedArgsDummy.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public function __construct(Dummy ...$foo)
2020
$this->foo = $foo;
2121
}
2222

23+
/** @return Dummy[] */
2324
public function getFoo()
2425
{
2526
return $this->foo;

src/Symfony/Component/Serializer/Tests/Normalizer/AbstractNormalizerTest.php

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
use PHPUnit\Framework\MockObject\MockObject;
66
use PHPUnit\Framework\TestCase;
7+
use Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor;
8+
use Symfony\Component\Serializer\Encoder\JsonEncoder;
79
use Symfony\Component\Serializer\Mapping\AttributeMetadata;
810
use Symfony\Component\Serializer\Mapping\ClassMetadata;
911
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface;
@@ -122,20 +124,51 @@ public function testObjectWithNullableConstructorArgument()
122124
$this->assertNull($dummy->getFoo());
123125
}
124126

125-
public function testObjectWithVariadicConstructorTypedArguments()
127+
/**
128+
* @dataProvider getNormalizer
129+
*/
130+
public function testObjectWithVariadicConstructorTypedArguments(AbstractNormalizer $normalizer)
126131
{
127-
$normalizer = new PropertyNormalizer();
128-
$normalizer->setSerializer(new Serializer([$normalizer]));
129-
$data = ['foo' => [['foo' => 'Foo', 'bar' => 'Bar', 'baz' => 'Baz', 'qux' => 'Qux'], ['foo' => 'FOO', 'bar' => 'BAR', 'baz' => 'BAZ', 'qux' => 'QUX']]];
130-
$dummy = $normalizer->denormalize($data, VariadicConstructorTypedArgsDummy::class);
132+
$d1 = new Dummy();
133+
$d1->foo = 'Foo';
134+
$d1->bar = 'Bar';
135+
$d1->baz = 'Baz';
136+
$d1->qux = 'Quz';
137+
$d2 = new Dummy();
138+
$d2->foo = 'FOO';
139+
$d2->bar = 'BAR';
140+
$d2->baz = 'BAZ';
141+
$d2->qux = 'QUZ';
142+
$obj = new VariadicConstructorTypedArgsDummy($d1, $d2);
143+
144+
$serializer = new Serializer([$normalizer], [new JsonEncoder()]);
145+
$normalizer->setSerializer($serializer);
146+
$data = $serializer->serialize($obj, 'json');
147+
$dummy = $normalizer->denormalize(json_decode($data, true), VariadicConstructorTypedArgsDummy::class);
148+
$this->assertInstanceOf(VariadicConstructorTypedArgsDummy::class, $dummy);
149+
$this->assertCount(2, $dummy->getFoo());
150+
foreach ($dummy->getFoo() as $foo) {
151+
$this->assertInstanceOf(Dummy::class, $foo);
152+
}
131153

154+
$dummy = $serializer->deserialize($data, VariadicConstructorTypedArgsDummy::class, 'json');
132155
$this->assertInstanceOf(VariadicConstructorTypedArgsDummy::class, $dummy);
133156
$this->assertCount(2, $dummy->getFoo());
134157
foreach ($dummy->getFoo() as $foo) {
135158
$this->assertInstanceOf(Dummy::class, $foo);
136159
}
137160
}
138161

162+
public function getNormalizer()
163+
{
164+
$extractor = new PhpDocExtractor();
165+
166+
yield [new PropertyNormalizer()];
167+
yield [new PropertyNormalizer(null, null, $extractor)];
168+
yield [new ObjectNormalizer()];
169+
yield [new ObjectNormalizer(null, null, null, $extractor)];
170+
}
171+
139172
public function testIgnore()
140173
{
141174
$classMetadata = new ClassMetadata(IgnoreDummy::class);

0 commit comments

Comments
 (0)