Skip to content

Commit

Permalink
More explicit message for denormalize exception
Browse files Browse the repository at this point in the history
  • Loading branch information
Korbeil committed Dec 27, 2019
1 parent b1f53ae commit 7ee6ca0
Show file tree
Hide file tree
Showing 96 changed files with 98 additions and 96 deletions.
Expand Up @@ -157,7 +157,9 @@ protected function denormalizeMethodStatements(ClassGuess $classGuess, Context $
[
'stmts' => [
$context->isStrict() ?
new Stmt\Throw_(new Expr\New_(new Name('InvalidArgumentException')))
new Stmt\Throw_(new Expr\New_(new Name('InvalidArgumentException'), [
new Expr\FuncCall(new Name('sprintf'), [new Arg(new Scalar\String_('Given $data is not an object (%s given). We need an object in order to continue denormalize method.')), new Arg(new Expr\FuncCall(new Name('gettype'), [new Arg(new Expr\Variable('data'))]))]),
]))
:
new Stmt\Return_(new Expr\ConstFetch(new Name('null'))),
],
Expand Down
Expand Up @@ -25,7 +25,7 @@ public function supportsNormalization($data, $format = null)
public function denormalize($data, $class, $format = null, array $context = array())
{
if (!is_object($data)) {
throw new InvalidArgumentException();
throw new InvalidArgumentException(sprintf('Given $data is not an object (%s given). We need an object in order to continue denormalize method.', gettype($data)));
}
if (isset($data->{'$ref'})) {
return new Reference($data->{'$ref'}, $context['document-origin']);
Expand Down
Expand Up @@ -25,7 +25,7 @@ public function supportsNormalization($data, $format = null)
public function denormalize($data, $class, $format = null, array $context = array())
{
if (!is_object($data)) {
throw new InvalidArgumentException();
throw new InvalidArgumentException(sprintf('Given $data is not an object (%s given). We need an object in order to continue denormalize method.', gettype($data)));
}
if (isset($data->{'$ref'})) {
return new Reference($data->{'$ref'}, $context['document-origin']);
Expand Down
Expand Up @@ -25,7 +25,7 @@ public function supportsNormalization($data, $format = null)
public function denormalize($data, $class, $format = null, array $context = array())
{
if (!is_object($data)) {
throw new InvalidArgumentException();
throw new InvalidArgumentException(sprintf('Given $data is not an object (%s given). We need an object in order to continue denormalize method.', gettype($data)));
}
$object = new \Jane\JsonSchema\Tests\Expected\Model\Bar();
if (property_exists($data, 'foo')) {
Expand Down
Expand Up @@ -25,7 +25,7 @@ public function supportsNormalization($data, $format = null)
public function denormalize($data, $class, $format = null, array $context = array())
{
if (!is_object($data)) {
throw new InvalidArgumentException();
throw new InvalidArgumentException(sprintf('Given $data is not an object (%s given). We need an object in order to continue denormalize method.', gettype($data)));
}
$object = new \Jane\JsonSchema\Tests\Expected\Model\BazBaz();
if (property_exists($data, 'baz')) {
Expand Down
Expand Up @@ -25,7 +25,7 @@ public function supportsNormalization($data, $format = null)
public function denormalize($data, $class, $format = null, array $context = array())
{
if (!is_object($data)) {
throw new InvalidArgumentException();
throw new InvalidArgumentException(sprintf('Given $data is not an object (%s given). We need an object in order to continue denormalize method.', gettype($data)));
}
$object = new \Jane\JsonSchema\Tests\Expected\Model\Baz();
if (property_exists($data, 'foo')) {
Expand Down
Expand Up @@ -25,7 +25,7 @@ public function supportsNormalization($data, $format = null)
public function denormalize($data, $class, $format = null, array $context = array())
{
if (!is_object($data)) {
throw new InvalidArgumentException();
throw new InvalidArgumentException(sprintf('Given $data is not an object (%s given). We need an object in order to continue denormalize method.', gettype($data)));
}
$object = new \Jane\JsonSchema\Tests\Expected\Model\Childtype();
if (property_exists($data, 'childProperty')) {
Expand Down
Expand Up @@ -25,7 +25,7 @@ public function supportsNormalization($data, $format = null)
public function denormalize($data, $class, $format = null, array $context = array())
{
if (!is_object($data)) {
throw new InvalidArgumentException();
throw new InvalidArgumentException(sprintf('Given $data is not an object (%s given). We need an object in order to continue denormalize method.', gettype($data)));
}
$object = new \Jane\JsonSchema\Tests\Expected\Model\Foo();
if (property_exists($data, 'foo')) {
Expand Down
Expand Up @@ -25,7 +25,7 @@ public function supportsNormalization($data, $format = null)
public function denormalize($data, $class, $format = null, array $context = array())
{
if (!is_object($data)) {
throw new InvalidArgumentException();
throw new InvalidArgumentException(sprintf('Given $data is not an object (%s given). We need an object in order to continue denormalize method.', gettype($data)));
}
$object = new \Jane\JsonSchema\Tests\Expected\Model\Otherchildtype();
if (property_exists($data, 'inheritedProperty')) {
Expand Down
Expand Up @@ -25,7 +25,7 @@ public function supportsNormalization($data, $format = null)
public function denormalize($data, $class, $format = null, array $context = array())
{
if (!is_object($data)) {
throw new InvalidArgumentException();
throw new InvalidArgumentException(sprintf('Given $data is not an object (%s given). We need an object in order to continue denormalize method.', gettype($data)));
}
$object = new \Jane\JsonSchema\Tests\Expected\Model\Parenttype();
if (property_exists($data, 'inheritedProperty')) {
Expand Down
Expand Up @@ -25,7 +25,7 @@ public function supportsNormalization($data, $format = null)
public function denormalize($data, $class, $format = null, array $context = array())
{
if (!is_object($data)) {
throw new InvalidArgumentException();
throw new InvalidArgumentException(sprintf('Given $data is not an object (%s given). We need an object in order to continue denormalize method.', gettype($data)));
}
$object = new \Jane\JsonSchema\Tests\Expected\Model\Test();
if (property_exists($data, 'child')) {
Expand Down
Expand Up @@ -25,7 +25,7 @@ public function supportsNormalization($data, $format = null)
public function denormalize($data, $class, $format = null, array $context = array())
{
if (!is_object($data)) {
throw new InvalidArgumentException();
throw new InvalidArgumentException(sprintf('Given $data is not an object (%s given). We need an object in order to continue denormalize method.', gettype($data)));
}
if (isset($data->{'$ref'})) {
return new Reference($data->{'$ref'}, $context['document-origin']);
Expand Down
Expand Up @@ -25,7 +25,7 @@ public function supportsNormalization($data, $format = null)
public function denormalize($data, $class, $format = null, array $context = array())
{
if (!is_object($data)) {
throw new InvalidArgumentException();
throw new InvalidArgumentException(sprintf('Given $data is not an object (%s given). We need an object in order to continue denormalize method.', gettype($data)));
}
if (isset($data->{'$ref'})) {
return new Reference($data->{'$ref'}, $context['document-origin']);
Expand Down
Expand Up @@ -25,7 +25,7 @@ public function supportsNormalization($data, $format = null)
public function denormalize($data, $class, $format = null, array $context = array())
{
if (!is_object($data)) {
throw new InvalidArgumentException();
throw new InvalidArgumentException(sprintf('Given $data is not an object (%s given). We need an object in order to continue denormalize method.', gettype($data)));
}
if (isset($data->{'$ref'})) {
return new Reference($data->{'$ref'}, $context['document-origin']);
Expand Down
Expand Up @@ -25,7 +25,7 @@ public function supportsNormalization($data, $format = null)
public function denormalize($data, $class, $format = null, array $context = array())
{
if (!is_object($data)) {
throw new InvalidArgumentException();
throw new InvalidArgumentException(sprintf('Given $data is not an object (%s given). We need an object in order to continue denormalize method.', gettype($data)));
}
if (isset($data->{'$ref'})) {
return new Reference($data->{'$ref'}, $context['document-origin']);
Expand Down
Expand Up @@ -25,7 +25,7 @@ public function supportsNormalization($data, $format = null)
public function denormalize($data, $class, $format = null, array $context = array())
{
if (!is_object($data)) {
throw new InvalidArgumentException();
throw new InvalidArgumentException(sprintf('Given $data is not an object (%s given). We need an object in order to continue denormalize method.', gettype($data)));
}
if (isset($data->{'$ref'})) {
return new Reference($data->{'$ref'}, $context['document-origin']);
Expand Down
Expand Up @@ -25,7 +25,7 @@ public function supportsNormalization($data, $format = null)
public function denormalize($data, $class, $format = null, array $context = array())
{
if (!is_object($data)) {
throw new InvalidArgumentException();
throw new InvalidArgumentException(sprintf('Given $data is not an object (%s given). We need an object in order to continue denormalize method.', gettype($data)));
}
if (isset($data->{'$ref'})) {
return new Reference($data->{'$ref'}, $context['document-origin']);
Expand Down
Expand Up @@ -25,7 +25,7 @@ public function supportsNormalization($data, $format = null)
public function denormalize($data, $class, $format = null, array $context = array())
{
if (!is_object($data)) {
throw new InvalidArgumentException();
throw new InvalidArgumentException(sprintf('Given $data is not an object (%s given). We need an object in order to continue denormalize method.', gettype($data)));
}
if (isset($data->{'$ref'})) {
return new Reference($data->{'$ref'}, $context['document-origin']);
Expand Down
Expand Up @@ -25,7 +25,7 @@ public function supportsNormalization($data, $format = null)
public function denormalize($data, $class, $format = null, array $context = array())
{
if (!is_object($data)) {
throw new InvalidArgumentException();
throw new InvalidArgumentException(sprintf('Given $data is not an object (%s given). We need an object in order to continue denormalize method.', gettype($data)));
}
if (isset($data->{'$ref'})) {
return new Reference($data->{'$ref'}, $context['document-origin']);
Expand Down
Expand Up @@ -25,7 +25,7 @@ public function supportsNormalization($data, $format = null)
public function denormalize($data, $class, $format = null, array $context = array())
{
if (!is_object($data)) {
throw new InvalidArgumentException();
throw new InvalidArgumentException(sprintf('Given $data is not an object (%s given). We need an object in order to continue denormalize method.', gettype($data)));
}
if (isset($data->{'$ref'})) {
return new Reference($data->{'$ref'}, $context['document-origin']);
Expand Down
Expand Up @@ -25,7 +25,7 @@ public function supportsNormalization($data, $format = null)
public function denormalize($data, $class, $format = null, array $context = array())
{
if (!is_object($data)) {
throw new InvalidArgumentException();
throw new InvalidArgumentException(sprintf('Given $data is not an object (%s given). We need an object in order to continue denormalize method.', gettype($data)));
}
if (isset($data->{'$ref'})) {
return new Reference($data->{'$ref'}, $context['document-origin']);
Expand Down
Expand Up @@ -25,7 +25,7 @@ public function supportsNormalization($data, $format = null)
public function denormalize($data, $class, $format = null, array $context = array())
{
if (!is_object($data)) {
throw new InvalidArgumentException();
throw new InvalidArgumentException(sprintf('Given $data is not an object (%s given). We need an object in order to continue denormalize method.', gettype($data)));
}
$object = new \Jane\JsonSchema\Tests\Expected\Model\TestFoo();
if (property_exists($data, 'foo')) {
Expand Down
Expand Up @@ -25,7 +25,7 @@ public function supportsNormalization($data, $format = null)
public function denormalize($data, $class, $format = null, array $context = array())
{
if (!is_object($data)) {
throw new InvalidArgumentException();
throw new InvalidArgumentException(sprintf('Given $data is not an object (%s given). We need an object in order to continue denormalize method.', gettype($data)));
}
$object = new \Jane\JsonSchema\Tests\Expected\Model\Test();
if (property_exists($data, 'foo')) {
Expand Down
Expand Up @@ -25,7 +25,7 @@ public function supportsNormalization($data, $format = null)
public function denormalize($data, $class, $format = null, array $context = array())
{
if (!is_object($data)) {
throw new InvalidArgumentException();
throw new InvalidArgumentException(sprintf('Given $data is not an object (%s given). We need an object in order to continue denormalize method.', gettype($data)));
}
$object = new \Jane\JsonSchema\Tests\Expected\Schema1\Model\Test();
if (property_exists($data, 'foo')) {
Expand Down
Expand Up @@ -25,7 +25,7 @@ public function supportsNormalization($data, $format = null)
public function denormalize($data, $class, $format = null, array $context = array())
{
if (!is_object($data)) {
throw new InvalidArgumentException();
throw new InvalidArgumentException(sprintf('Given $data is not an object (%s given). We need an object in order to continue denormalize method.', gettype($data)));
}
$object = new \Jane\JsonSchema\Tests\Expected\Schema2\Model\Foo();
if (property_exists($data, 'foo')) {
Expand Down
Expand Up @@ -25,7 +25,7 @@ public function supportsNormalization($data, $format = null)
public function denormalize($data, $class, $format = null, array $context = array())
{
if (!is_object($data)) {
throw new InvalidArgumentException();
throw new InvalidArgumentException(sprintf('Given $data is not an object (%s given). We need an object in order to continue denormalize method.', gettype($data)));
}
if (isset($data->{'$ref'})) {
return new Reference($data->{'$ref'}, $context['document-origin']);
Expand Down
Expand Up @@ -25,7 +25,7 @@ public function supportsNormalization($data, $format = null)
public function denormalize($data, $class, $format = null, array $context = array())
{
if (!is_object($data)) {
throw new InvalidArgumentException();
throw new InvalidArgumentException(sprintf('Given $data is not an object (%s given). We need an object in order to continue denormalize method.', gettype($data)));
}
if (isset($data->{'$ref'})) {
return new Reference($data->{'$ref'}, $context['document-origin']);
Expand Down
Expand Up @@ -25,7 +25,7 @@ public function supportsNormalization($data, $format = null)
public function denormalize($data, $class, $format = null, array $context = array())
{
if (!is_object($data)) {
throw new InvalidArgumentException();
throw new InvalidArgumentException(sprintf('Given $data is not an object (%s given). We need an object in order to continue denormalize method.', gettype($data)));
}
if (isset($data->{'$ref'})) {
return new Reference($data->{'$ref'}, $context['document-origin']);
Expand Down
Expand Up @@ -25,7 +25,7 @@ public function supportsNormalization($data, $format = null)
public function denormalize($data, $class, $format = null, array $context = array())
{
if (!is_object($data)) {
throw new InvalidArgumentException();
throw new InvalidArgumentException(sprintf('Given $data is not an object (%s given). We need an object in order to continue denormalize method.', gettype($data)));
}
if (isset($data->{'$ref'})) {
return new Reference($data->{'$ref'}, $context['document-origin']);
Expand Down
Expand Up @@ -25,7 +25,7 @@ public function supportsNormalization($data, $format = null)
public function denormalize($data, $class, $format = null, array $context = array())
{
if (!is_object($data)) {
throw new InvalidArgumentException();
throw new InvalidArgumentException(sprintf('Given $data is not an object (%s given). We need an object in order to continue denormalize method.', gettype($data)));
}
$object = new \Jane\JsonSchema\Tests\Expected\Model\Test();
if (property_exists($data, 'string')) {
Expand Down
Expand Up @@ -25,7 +25,7 @@ public function supportsNormalization($data, $format = null)
public function denormalize($data, $class, $format = null, array $context = array())
{
if (!is_object($data)) {
throw new InvalidArgumentException();
throw new InvalidArgumentException(sprintf('Given $data is not an object (%s given). We need an object in order to continue denormalize method.', gettype($data)));
}
$object = new \Jane\JsonSchema\Tests\Expected\Model\TestSubObject();
if (property_exists($data, 'foo')) {
Expand Down
Expand Up @@ -25,7 +25,7 @@ public function supportsNormalization($data, $format = null)
public function denormalize($data, $class, $format = null, array $context = array())
{
if (!is_object($data)) {
throw new InvalidArgumentException();
throw new InvalidArgumentException(sprintf('Given $data is not an object (%s given). We need an object in order to continue denormalize method.', gettype($data)));
}
if (isset($data->{'$ref'})) {
return new Reference($data->{'$ref'}, $context['document-origin']);
Expand Down
Expand Up @@ -25,7 +25,7 @@ public function supportsNormalization($data, $format = null)
public function denormalize($data, $class, $format = null, array $context = array())
{
if (!is_object($data)) {
throw new InvalidArgumentException();
throw new InvalidArgumentException(sprintf('Given $data is not an object (%s given). We need an object in order to continue denormalize method.', gettype($data)));
}
$object = new \Jane\OpenApi\Tests\Expected\Model\Bar();
if (property_exists($data, 'bar')) {
Expand Down
Expand Up @@ -25,7 +25,7 @@ public function supportsNormalization($data, $format = null)
public function denormalize($data, $class, $format = null, array $context = array())
{
if (!is_object($data)) {
throw new InvalidArgumentException();
throw new InvalidArgumentException(sprintf('Given $data is not an object (%s given). We need an object in order to continue denormalize method.', gettype($data)));
}
$object = new \Jane\OpenApi\Tests\Expected\Model\Foo();
if (property_exists($data, 'bar')) {
Expand Down
Expand Up @@ -25,7 +25,7 @@ public function supportsNormalization($data, $format = null)
public function denormalize($data, $class, $format = null, array $context = array())
{
if (!is_object($data)) {
throw new InvalidArgumentException();
throw new InvalidArgumentException(sprintf('Given $data is not an object (%s given). We need an object in order to continue denormalize method.', gettype($data)));
}
$object = new \Jane\OpenApi\Tests\Expected\Model\Fuz();
if (property_exists($data, 'bar')) {
Expand Down

0 comments on commit 7ee6ca0

Please sign in to comment.