| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
namespace Symfony\Component\Serializer\Attribute; |
| 13 |
|
| 14 |
use Symfony\Component\Serializer\Exception\InvalidArgumentException; |
| 15 |
|
| 16 |
|
| 17 |
> |
| 18 |
|
| 19 |
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY)] |
| 20 |
class MaxDepth |
| 21 |
{ |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
public function __construct( |
| 26 |
public readonly int $maxDepth, |
| 27 |
) { |
| 28 |
if ($maxDepth <= 0) { |
| 29 |
throw new InvalidArgumentException(\sprintf('Parameter given to "%s" must be a positive integer.', static::class)); |
| 30 |
} |
| 31 |
} |
| 32 |
|
| 33 |
#[\Deprecated('Use the "maxdepth" property instead', 'symfony/serializer:7.4')] |
| 34 |
public function getMaxDepth(): int |
| 35 |
{ |
| 36 |
return $this->maxDepth; |
| 37 |
} |
| 38 |
} |
| 39 |
|
| 40 |
if (!class_exists(\Symfony\Component\Serializer\Annotation\MaxDepth::class, false)) { |
| 41 |
class_alias(MaxDepth::class, \Symfony\Component\Serializer\Annotation\MaxDepth::class); |
| 42 |
} |