Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9e6dd9a

Browse files
committed
Fabbot patches
1 parent0750033 commit9e6dd9a

File tree

2 files changed

+164
-167
lines changed

2 files changed

+164
-167
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -702,9 +702,9 @@ private function updateData(array $data, string $attribute, mixed $attributeValu
702702

703703
if ($this->nameConverter) {
704704
$attribute =$this->nameConverter->normalize($attribute,$class,$format,$context);
705-
}elseif ($flattenNestedAttributes) {
706-
thrownewLogicException('A metadata aware name converter must be provided in the constructor when setting "flatten_nested_attributes" to true.');
707-
}
705+
}elseif ($flattenNestedAttributes) {
706+
thrownewLogicException('A metadata aware name converter must be provided in the constructor when setting "flatten_nested_attributes" to true.');
707+
}
708708

709709
if ($flattenNestedAttributes &&false !==strpos($attribute,self::FLATTENER)) {
710710
$elements =explode(self::FLATTENER,$attribute);
@@ -854,7 +854,7 @@ private function setNestedValue($data, $elements, $value)
854854
thrownewLogicException(sprintf('The element you are trying to set is already populated: "%s".',$element));
855855
}
856856
if (0 ===\count($elements)) {
857-
$data[$element] =$value;
857+
$data[$element] =$value;
858858
}else {
859859
if (!isset($data[$element])) {
860860
$data[$element] = [];

‎src/Symfony/Component/Serializer/Tests/Normalizer/AbstractObjectNormalizerTest.php‎

Lines changed: 160 additions & 163 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
useSymfony\Component\PropertyInfo\Extractor\PhpDocExtractor;
1717
useSymfony\Component\PropertyInfo\Type;
1818
useSymfony\Component\Serializer\Annotation\SerializedName;
19-
useSymfony\Component\Serializer\Encoder\JsonEncoder;
20-
useSymfony\Component\Serializer\Encoder\XmlEncoder;
2119
useSymfony\Component\Serializer\Exception\ExtraAttributesException;
2220
useSymfony\Component\Serializer\Exception\InvalidArgumentException;
2321
useSymfony\Component\Serializer\Exception\LogicException;
@@ -106,146 +104,146 @@ public function testDenormalizeWithExtraAttributesAndNoGroupsWithMetadataFactory
106104
);
107105
}
108106

109-
publicfunctiontestDenormalizeWithNestedAttributesAndNoMetadataFactory()
110-
{
111-
$this->expectException(LogicException::class);
107+
publicfunctiontestDenormalizeWithNestedAttributesAndNoMetadataFactory()
108+
{
109+
$this->expectException(LogicException::class);
112110
$this->expectExceptionMessage('A class metadata factory must be provided in the constructor when setting "flatten_nested_attributes" to true.');
113-
$normalizer =newObjectNormalizer();
114-
$normalizer->denormalize(
115-
[],
116-
NestedDummy::class,
117-
'any',
118-
['flatten_nested_attributes' =>true]
119-
);
120-
}
121-
122-
publicfunctiontestDenormalizeWithDuplicateNestedAttributes()
123-
{
124-
$this->expectException(LogicException::class);
111+
$normalizer =newObjectNormalizer();
112+
$normalizer->denormalize(
113+
[],
114+
NestedDummy::class,
115+
'any',
116+
['flatten_nested_attributes' =>true]
117+
);
118+
}
119+
120+
publicfunctiontestDenormalizeWithDuplicateNestedAttributes()
121+
{
122+
$this->expectException(LogicException::class);
125123
$this->expectExceptionMessage('Duplicate serialized name: "one.two.three"');
126124
$normalizer =newAbstractObjectNormalizerWithMetadata();
127-
$normalizer->denormalize(
128-
[],
129-
DuplicateNestedDummy::class,
130-
'any',
131-
['flatten_nested_attributes' =>true]
132-
);
133-
}
134-
135-
publicfunctiontestDenormalizeWithNestedAttributes()
136-
{
125+
$normalizer->denormalize(
126+
[],
127+
DuplicateNestedDummy::class,
128+
'any',
129+
['flatten_nested_attributes' =>true]
130+
);
131+
}
132+
133+
publicfunctiontestDenormalizeWithNestedAttributes()
134+
{
137135
$normalizer =newAbstractObjectNormalizerWithMetadata();
138-
$data = [
139-
'one' => [
140-
'two' => [
141-
'three' =>'foo'
142-
],
143-
'four' =>'bar'
144-
]
145-
];
146-
$test =$normalizer->denormalize(
147-
$data,
148-
NestedDummy::class,
149-
'any',
150-
['flatten_nested_attributes' =>true]
151-
);
152-
$this->assertEquals('foo',$test->foo);
153-
$this->assertEquals('bar',$test->bar);
154-
}
155-
156-
publicfunctiontestNormalizeWithNestedAttributesAndNoMetadataNameConverter()
157-
{
158-
$this->expectException(LogicException::class);
136+
$data = [
137+
'one' => [
138+
'two' => [
139+
'three' =>'foo',
140+
],
141+
'four' =>'bar',
142+
],
143+
];
144+
$test =$normalizer->denormalize(
145+
$data,
146+
NestedDummy::class,
147+
'any',
148+
['flatten_nested_attributes' =>true]
149+
);
150+
$this->assertEquals('foo',$test->foo);
151+
$this->assertEquals('bar',$test->bar);
152+
}
153+
154+
publicfunctiontestNormalizeWithNestedAttributesAndNoMetadataNameConverter()
155+
{
156+
$this->expectException(LogicException::class);
159157
$this->expectExceptionMessage('A metadata aware name converter must be provided in the constructor when setting "flatten_nested_attributes" to true.');
160-
$foobar =newNestedDummy();
161-
$foobar->foo ='foo';
162-
$foobar->bar ='bar';
163-
$normalizer =newObjectNormalizer();
164-
$normalizer->normalize(
165-
$foobar,
166-
'any',
167-
['flatten_nested_attributes' =>true]
168-
);
169-
}
170-
171-
publicfunctiontestNormalizeWithNestedAttributesMixingArrayTypes()
172-
{
173-
$this->expectException(LogicException::class);
158+
$foobar =newNestedDummy();
159+
$foobar->foo ='foo';
160+
$foobar->bar ='bar';
161+
$normalizer =newObjectNormalizer();
162+
$normalizer->normalize(
163+
$foobar,
164+
'any',
165+
['flatten_nested_attributes' =>true]
166+
);
167+
}
168+
169+
publicfunctiontestNormalizeWithNestedAttributesMixingArrayTypes()
170+
{
171+
$this->expectException(LogicException::class);
174172
$this->expectExceptionMessage('The element you are trying to set is already populated: "two"');
175-
$foobar =newAlreadyPopulatedNestedDummy();
176-
$foobar->foo ='foo';
177-
$foobar->bar ='bar';
178-
$normalizer =newObjectNormalizer(
179-
null,
180-
newMetadataAwareNameConverter(
181-
newClassMetadataFactory(
182-
newAnnotationLoader(
183-
newAnnotationReader()
184-
)
185-
)
186-
)
187-
);
188-
$normalizer->normalize(
189-
$foobar,
190-
'any',
191-
['flatten_nested_attributes' =>true]
192-
);
193-
}
194-
195-
publicfunctiontestNormalizeWithNestedAttributesElementAlreadySet()
196-
{
197-
$this->expectException(LogicException::class);
173+
$foobar =newAlreadyPopulatedNestedDummy();
174+
$foobar->foo ='foo';
175+
$foobar->bar ='bar';
176+
$normalizer =newObjectNormalizer(
177+
null,
178+
newMetadataAwareNameConverter(
179+
newClassMetadataFactory(
180+
newAnnotationLoader(
181+
newAnnotationReader()
182+
)
183+
)
184+
)
185+
);
186+
$normalizer->normalize(
187+
$foobar,
188+
'any',
189+
['flatten_nested_attributes' =>true]
190+
);
191+
}
192+
193+
publicfunctiontestNormalizeWithNestedAttributesElementAlreadySet()
194+
{
195+
$this->expectException(LogicException::class);
198196
$this->expectExceptionMessage('The element you are trying to set is already populated: "three"');
199-
$foobar =newDuplicateNestedDummy();
200-
$foobar->foo ='foo';
201-
$foobar->bar ='bar';
202-
$normalizer =newObjectNormalizer(
203-
null,
204-
newMetadataAwareNameConverter(
205-
newClassMetadataFactory(
206-
newAnnotationLoader(
207-
newAnnotationReader()
208-
)
209-
)
210-
)
211-
);
212-
$normalizer->normalize(
213-
$foobar,
214-
'any',
215-
['flatten_nested_attributes' =>true]
216-
);
217-
}
218-
219-
publicfunctiontestNormalizeWithNestedAttributes()
220-
{
221-
$foobar =newNestedDummy();
222-
$foobar->foo ='foo';
223-
$foobar->bar ='bar';
224-
$data = [
225-
'one' => [
226-
'two' => [
227-
'three' =>'foo'
228-
],
229-
'four' =>'bar'
230-
]
231-
];
232-
$normalizer =newObjectNormalizer(
233-
null,
234-
newMetadataAwareNameConverter(
235-
newClassMetadataFactory(
236-
newAnnotationLoader(
237-
newAnnotationReader()
238-
)
239-
)
240-
)
241-
);
242-
$test =$normalizer->normalize(
243-
$foobar,
244-
'any',
245-
['flatten_nested_attributes' =>true]
246-
);
247-
$this->assertEquals($data,$test);
248-
}
197+
$foobar =newDuplicateNestedDummy();
198+
$foobar->foo ='foo';
199+
$foobar->bar ='bar';
200+
$normalizer =newObjectNormalizer(
201+
null,
202+
newMetadataAwareNameConverter(
203+
newClassMetadataFactory(
204+
newAnnotationLoader(
205+
newAnnotationReader()
206+
)
207+
)
208+
)
209+
);
210+
$normalizer->normalize(
211+
$foobar,
212+
'any',
213+
['flatten_nested_attributes' =>true]
214+
);
215+
}
216+
217+
publicfunctiontestNormalizeWithNestedAttributes()
218+
{
219+
$foobar =newNestedDummy();
220+
$foobar->foo ='foo';
221+
$foobar->bar ='bar';
222+
$data = [
223+
'one' => [
224+
'two' => [
225+
'three' =>'foo',
226+
],
227+
'four' =>'bar',
228+
],
229+
];
230+
$normalizer =newObjectNormalizer(
231+
null,
232+
newMetadataAwareNameConverter(
233+
newClassMetadataFactory(
234+
newAnnotationLoader(
235+
newAnnotationReader()
236+
)
237+
)
238+
)
239+
);
240+
$test =$normalizer->normalize(
241+
$foobar,
242+
'any',
243+
['flatten_nested_attributes' =>true]
244+
);
245+
$this->assertEquals($data,$test);
246+
}
249247

250248
publicfunctiontestDenormalizeCollectionDecodedFromXmlWithOneChild()
251249
{
@@ -574,42 +572,41 @@ class EmptyDummy
574572

575573
class AlreadyPopulatedNestedDummy
576574
{
577-
/**
578-
* @SerializedName("one.two.three")
579-
*/
580-
public$foo;
581-
582-
/**
583-
* @SerializedName("one.two")
584-
*/
585-
public$bar;
586-
}
575+
/**
576+
* @SerializedName("one.two.three")
577+
*/
578+
public$foo;
587579

580+
/**
581+
* @SerializedName("one.two")
582+
*/
583+
public$bar;
584+
}
588585

589586
class DuplicateNestedDummy
590587
{
591-
/**
592-
* @SerializedName("one.two.three")
593-
*/
594-
public$foo;
595-
596-
/**
597-
* @SerializedName("one.two.three")
598-
*/
599-
public$bar;
588+
/**
589+
* @SerializedName("one.two.three")
590+
*/
591+
public$foo;
592+
593+
/**
594+
* @SerializedName("one.two.three")
595+
*/
596+
public$bar;
600597
}
601598

602599
class NestedDummy
603600
{
604-
/**
605-
* @SerializedName("one.two.three")
606-
*/
607-
public$foo;
608-
609-
/**
610-
* @SerializedName("one.four")
611-
*/
612-
public$bar;
601+
/**
602+
* @SerializedName("one.two.three")
603+
*/
604+
public$foo;
605+
606+
/**
607+
* @SerializedName("one.four")
608+
*/
609+
public$bar;
613610
}
614611

615612
class AbstractObjectNormalizerWithMetadataextends AbstractObjectNormalizer

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp