Skip to content

Commit 73820ab

Browse files
javaDeveloperKidnicolas-grekas
authored andcommitted
[Serializer] Add AbstractNormalizerContextBuilder::defaultConstructorArguments()
1 parent 23bc636 commit 73820ab

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

Context/Normalizer/AbstractNormalizerContextBuilder.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,17 +104,25 @@ public function withAllowExtraAttributes(?bool $allowExtraAttributes): static
104104
}
105105

106106
/**
107-
* Configures an hashmap of classes containing hashmaps of constructor argument => default value.
107+
* Configures a hashmap of classes containing hashmaps of constructor argument => default value.
108108
*
109109
* The names need to match the parameter names in the constructor arguments.
110110
*
111111
* Eg: [Foo::class => ['foo' => true, 'bar' => 0]]
112112
*
113-
* @param array<class-string, array<string, mixed>>|null $defaultContructorArguments
113+
* @param array<class-string, array<string, mixed>>|null $defaultConstructorArguments
114+
*/
115+
public function withDefaultConstructorArguments(?array $defaultConstructorArguments): static
116+
{
117+
return $this->with(AbstractNormalizer::DEFAULT_CONSTRUCTOR_ARGUMENTS, $defaultConstructorArguments);
118+
}
119+
120+
/**
121+
* Deprecated in Symfony 7.1, use withDefaultConstructorArguments() instead.
114122
*/
115123
public function withDefaultContructorArguments(?array $defaultContructorArguments): static
116124
{
117-
return $this->with(AbstractNormalizer::DEFAULT_CONSTRUCTOR_ARGUMENTS, $defaultContructorArguments);
125+
return self::withDefaultConstructorArguments($defaultContructorArguments);
118126
}
119127

120128
/**

Tests/Context/Normalizer/AbstractNormalizerContextBuilderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function testWithers(array $values)
4141
->withGroups($values[AbstractNormalizer::GROUPS])
4242
->withAttributes($values[AbstractNormalizer::ATTRIBUTES])
4343
->withAllowExtraAttributes($values[AbstractNormalizer::ALLOW_EXTRA_ATTRIBUTES])
44-
->withDefaultContructorArguments($values[AbstractNormalizer::DEFAULT_CONSTRUCTOR_ARGUMENTS])
44+
->withDefaultConstructorArguments($values[AbstractNormalizer::DEFAULT_CONSTRUCTOR_ARGUMENTS])
4545
->withCallbacks($values[AbstractNormalizer::CALLBACKS])
4646
->withCircularReferenceHandler($values[AbstractNormalizer::CIRCULAR_REFERENCE_HANDLER])
4747
->withIgnoredAttributes($values[AbstractNormalizer::IGNORED_ATTRIBUTES])

0 commit comments

Comments
 (0)