Skip to content

Commit

Permalink
[Serializer] Add AbstractNormalizerContextBuilder::defaultConstructor…
Browse files Browse the repository at this point in the history
…Arguments()
  • Loading branch information
javaDeveloperKid authored and nicolas-grekas committed Apr 23, 2024
1 parent 23bc636 commit 73820ab
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
14 changes: 11 additions & 3 deletions Context/Normalizer/AbstractNormalizerContextBuilder.php
Expand Up @@ -104,17 +104,25 @@ public function withAllowExtraAttributes(?bool $allowExtraAttributes): static
}

/**
* Configures an hashmap of classes containing hashmaps of constructor argument => default value.
* Configures a hashmap of classes containing hashmaps of constructor argument => default value.
*
* The names need to match the parameter names in the constructor arguments.
*
* Eg: [Foo::class => ['foo' => true, 'bar' => 0]]
*
* @param array<class-string, array<string, mixed>>|null $defaultContructorArguments
* @param array<class-string, array<string, mixed>>|null $defaultConstructorArguments
*/
public function withDefaultConstructorArguments(?array $defaultConstructorArguments): static
{
return $this->with(AbstractNormalizer::DEFAULT_CONSTRUCTOR_ARGUMENTS, $defaultConstructorArguments);
}

/**
* Deprecated in Symfony 7.1, use withDefaultConstructorArguments() instead.
*/
public function withDefaultContructorArguments(?array $defaultContructorArguments): static
{
return $this->with(AbstractNormalizer::DEFAULT_CONSTRUCTOR_ARGUMENTS, $defaultContructorArguments);
return self::withDefaultConstructorArguments($defaultContructorArguments);
}

/**
Expand Down
Expand Up @@ -41,7 +41,7 @@ public function testWithers(array $values)
->withGroups($values[AbstractNormalizer::GROUPS])
->withAttributes($values[AbstractNormalizer::ATTRIBUTES])
->withAllowExtraAttributes($values[AbstractNormalizer::ALLOW_EXTRA_ATTRIBUTES])
->withDefaultContructorArguments($values[AbstractNormalizer::DEFAULT_CONSTRUCTOR_ARGUMENTS])
->withDefaultConstructorArguments($values[AbstractNormalizer::DEFAULT_CONSTRUCTOR_ARGUMENTS])
->withCallbacks($values[AbstractNormalizer::CALLBACKS])
->withCircularReferenceHandler($values[AbstractNormalizer::CIRCULAR_REFERENCE_HANDLER])
->withIgnoredAttributes($values[AbstractNormalizer::IGNORED_ATTRIBUTES])
Expand Down

0 comments on commit 73820ab

Please sign in to comment.