Skip to content

Commit

Permalink
Add @throws annotations in DenormalizerInterface::denormalize() and N…
Browse files Browse the repository at this point in the history
…ormalizerInterface::normalize().
  • Loading branch information
hxv authored and ondrejmirtes committed Feb 1, 2023
1 parent 2107dee commit cbf5b9c
Show file tree
Hide file tree
Showing 11 changed files with 102 additions and 0 deletions.
8 changes: 8 additions & 0 deletions extension.neon
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ parameters:
- stubs/Symfony/Component/Serializer/Encoder/ContextAwareDecoderInterface.stub
- stubs/Symfony/Component/Serializer/Encoder/DecoderInterface.stub
- stubs/Symfony/Component/Serializer/Encoder/EncoderInterface.stub
- stubs/Symfony/Component/Serializer/Exception/BadMethodCallException.stub
- stubs/Symfony/Component/Serializer/Exception/CircularReferenceException.stub
- stubs/Symfony/Component/Serializer/Exception/ExceptionInterface.stub
- stubs/Symfony/Component/Serializer/Exception/ExtraAttributesException.stub
- stubs/Symfony/Component/Serializer/Exception/InvalidArgumentException.stub
- stubs/Symfony/Component/Serializer/Exception/LogicException.stub
- stubs/Symfony/Component/Serializer/Exception/RuntimeException.stub
- stubs/Symfony/Component/Serializer/Exception/UnexpectedValueException.stub
- stubs/Symfony/Component/Serializer/Normalizer/ContextAwareDenormalizerInterface.stub
- stubs/Symfony/Component/Serializer/Normalizer/ContextAwareNormalizerInterface.stub
- stubs/Symfony/Component/Serializer/Normalizer/DenormalizableInterface.stub
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace Symfony\Component\Serializer\Exception;

class BadMethodCallException extends \BadMethodCallException implements ExceptionInterface
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace Symfony\Component\Serializer\Exception;

class CircularReferenceException extends RuntimeException
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace Symfony\Component\Serializer\Exception;

interface ExceptionInterface extends \Throwable
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Symfony\Component\Serializer\Exception;

class ExtraAttributesException extends RuntimeException
{
/**
* @param string[] $extraAttributes
*/
public function __construct(array $extraAttributes, \Throwable $previous = null)
{
}

/**
* @return string[]
*/
public function getExtraAttributes()
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace Symfony\Component\Serializer\Exception;

class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace Symfony\Component\Serializer\Exception;

class LogicException extends \LogicException implements ExceptionInterface
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace Symfony\Component\Serializer\Exception;

class RuntimeException extends \RuntimeException implements ExceptionInterface
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace Symfony\Component\Serializer\Exception;

class UnexpectedValueException extends \UnexpectedValueException implements ExceptionInterface
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

namespace Symfony\Component\Serializer\Normalizer;

use Symfony\Component\Serializer\Exception\BadMethodCallException;
use Symfony\Component\Serializer\Exception\ExceptionInterface;
use Symfony\Component\Serializer\Exception\ExtraAttributesException;
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
use Symfony\Component\Serializer\Exception\LogicException;
use Symfony\Component\Serializer\Exception\RuntimeException;
use Symfony\Component\Serializer\Exception\UnexpectedValueException;

interface DenormalizerInterface
{
/**
Expand All @@ -10,6 +18,14 @@ interface DenormalizerInterface
* @param string|null $format
* @param array<mixed> $context
* @return mixed
*
* @throws BadMethodCallException
* @throws InvalidArgumentException
* @throws UnexpectedValueException
* @throws ExtraAttributesException
* @throws LogicException
* @throws RuntimeException
* @throws ExceptionInterface
*/
public function denormalize($data, $type, $format = null, array $context = []);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
namespace Symfony\Component\Serializer\Normalizer;

use ArrayObject;
use Symfony\Component\Serializer\Exception\CircularReferenceException;
use Symfony\Component\Serializer\Exception\ExceptionInterface;
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
use Symfony\Component\Serializer\Exception\LogicException;

interface NormalizerInterface
{
Expand All @@ -12,6 +16,11 @@ interface NormalizerInterface
* @param array<mixed> $context
*
* @return array<mixed>|ArrayObject<array-key, mixed>|string|int|float|bool|null
*
* @throws InvalidArgumentException
* @throws CircularReferenceException
* @throws LogicException
* @throws ExceptionInterface
*/
public function normalize($object, $format = null, array $context = []);

Expand Down

0 comments on commit cbf5b9c

Please sign in to comment.