Skip to content

Commit

Permalink
deprecate calling createChildContext without the format parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
dbu committed Apr 26, 2019
1 parent 77f642e commit fb73b72
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Expand Up @@ -486,8 +486,12 @@ protected function denormalizeParameter(\ReflectionClass $class, \ReflectionPara
*
* @internal
*/
protected function createChildContext(array $parentContext, $attribute/*, string $format = null */)
protected function createChildContext(array $parentContext, $attribute/*, ?string $format */)
{
if (\func_num_args() < 3) {
@trigger_error(sprintf('Method %s::%s() will have a 3rd `?string $format` argument in version 5.0. Not defining it is deprecated since Symfony 4.3.', \get_class($this), __FUNCTION__), E_USER_DEPRECATED);
$format = null;
}
if (isset($parentContext[self::ATTRIBUTES][$attribute])) {
$parentContext[self::ATTRIBUTES] = $parentContext[self::ATTRIBUTES][$attribute];
} else {
Expand Down
Expand Up @@ -512,18 +512,19 @@ private function isMaxDepthReached(array $attributesMetadata, string $class, str
* We must not mix up the attribute cache between parent and children.
*
* {@inheritdoc}
*
* @param string|null $format
*/
protected function createChildContext(array $parentContext, $attribute/*, string $format = null */)
protected function createChildContext(array $parentContext, $attribute/*, ?string $format */)
{
if (\func_num_args() >= 3) {
$format = \func_get_arg(2);
} else {
// will be deprecated in version 4
@trigger_error(sprintf('Method %s::%s() will have a 3rd `?string $format` argument in version 5.0. Not defining it is deprecated since Symfony 4.3.', \get_class($this), __FUNCTION__), E_USER_DEPRECATED);
$format = null;
}

$context = parent::createChildContext($parentContext, $attribute, $format);
// format is already included in the cache_key of the parent.
$context['cache_key'] = $this->getCacheKey($format, $context);

return $context;
Expand Down

0 comments on commit fb73b72

Please sign in to comment.