8000 [Serializer] Argument objects by theofidry · Pull Request #19277 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Serializer] Argument objects #19277

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Jul 11, 2016
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 3 additions & 12 deletions src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,17 +268,6 @@ protected function getConstructor(array &$data, $class, array &$context, \Reflec
return $reflectionClass->getConstructor();
}

/**
* @see instantiateComplexObject
* @deprecated Since 3.1, will be removed in 4.0. Use instantiateComplexObject instead.
*/
protected function instantiateObject(array &$data, $class, array &$context, \ReflectionClass $reflectionClass, $allowedAttributes)
{
@trigger_error(sprintf('"%s()" has been deprecated since Symfony 3.1 and will be removed in version 4.0. Use "%s::instantiateComplexObject()" instead.', __METHOD__, __CLASS__), E_USER_DEPRECATED);

return $this->instantiateComplexObject($data, $class, $context, $reflectionClass, $allowedAttributes);
}

/**
* Instantiates an object using constructor parameters when needed.
*
Expand All @@ -298,8 +287,10 @@ protected function instantiateObject(array &$data, $class, array &$context, \Ref
*
* @throws RuntimeException
*/
protected function instantiateComplexObject(array &$data, $class, array &$context, \ReflectionClass $reflectionClass, $allowedAttributes, $format = null)
protected function instantiateObject(array &$data, $class, array &$context, \ReflectionClass $reflectionClass, $allowedAttributes/*, $format = null*/)
{
$format = func_num_args() >= 6 ? func_get_arg(5) : null;

if (
isset($context[static::OBJECT_TO_POPULATE]) &&
is_object($context[static::OBJECT_TO_POPULATE]) &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public function denormalize($data, $class, $format = null, array $context = arra
$normalizedData = $this->prepareForDenormalization($data);

$reflectionClass = new \ReflectionClass($class);
$object = $this->instantiateComplexObject($normalizedData, $class, $context, $reflectionClass, $allowedAttributes, $format);
$object = $this->instantiateObject($normalizedData, $class, $context, $reflectionClass, $allowedAttributes, $format);

foreach ($normalizedData as $attribute => $value) {
if ($this->nameConverter) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function denormalize($data, $class, $format = null, array $context = arra
$normalizedData = $this->prepareForDenormalization($data);

$reflectionClass = new \ReflectionClass($class);
$object = $this->instantiateComplexObject($normalizedData, $class, $context, $reflectionClass, $allowedAttributes, $format);
$object = $this->instantiateObject($normalizedData, $class, $context, $reflectionClass, $allowedAttributes, $format);

$classMethods = get_class_methods($object);
foreach ($normalizedData as $attribute => $value) {
Expand Down
0