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 ab0c58d commit 2709721
Show file tree
Hide file tree
Showing 96 changed files with 98 additions and 96 deletions.
Original file line number Diff line number Diff line change
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 Arg(new Expr\ConstFetch(new Name('Given $data isn\'t an object. We need an object in order to continue denormalize method.')))]))
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 2709721

Please sign in to comment.