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 1 commit
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
Prev Previous commit
Next Next commit
Add deprecation message
  • Loading branch information
theofidry committed Jul 5, 2016
commit 93608dcea0c3a394d90e9219a6c0f356c045f9fc
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,8 @@ protected function getConstructor(array &$data, $class, array &$context, \Reflec
*/
protected function instantiateObject(array &$data, $class, array &$context, \ReflectionClass $reflectionClass, $allowedAttributes)
{
@trigger_error(sprintf('"%s()" has been deprecated sin Symfony 3.1 and will be removed in version 4.0. Use "%s::instantiateComplexObject()" instead.', __METHOD__, __CLASS__));
Copy link
Contributor
@GuilhemN GuilhemN Jul 5, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since version 3.2 and @trigger_error(sprintf('...'), E_USER_DEPRECATED);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm quite surprised this went undetected by the phpunit bridge...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@theofidry phpunit bridge only discovers deprecated errors, not general silenced errors.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wouterj but I have a test with the @legacy group, so I guess I expected it to warn me or throw me an error if no deprecation notice were discovered


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

Expand Down
Original file line number Diff line number Diff line change
9B8C Expand Up @@ -24,6 +24,19 @@ public function testDenormalize()
$this->assertNull($normalizedData->bar);
$this->assertSame('baz', $normalizedData->baz);
}

/**
* @group legacy
*/
public function testInstantiateObjectDenormalizer()
{
$data = array('foo' => 'foo', 'bar' => 'bar', 'baz' => 'baz');
$class = __NAMESPACE__.'\Dummy';
$context = [];

$normalizer = new AbstractObjectNormalizerDummy();
$normalizer->instantiateObject($data, $class, $context, new \ReflectionClass($class), []);
}
}

class AbstractObjectNormalizerDummy extends AbstractObjectNormalizer
Expand All @@ -45,6 +58,13 @@ protected function isAllowedAttribute($classOrObject, $attribute, $format = null
{
return in_array($attribute, array('foo', 'baz'));
}

public function instantiateObject(array &$data, $class, array &$context, \ReflectionClass $reflectionClass, $allowedAttributes)
{
return parent::instantiateObject($data, $class, $context, $reflectionClass, $allowedAttributes);
}


}

class Dummy
Expand Down
0