Debian Codegraph @

lib/3rdParty/composer/symfony/serializer/Attribute/MaxDepth.php

raw symbols SCIP
1 <?php
2
3 /*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <[email protected]>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 namespace Symfony\Component\Serializer\Attribute;
13
14 use Symfony\Component\Serializer\Exception\InvalidArgumentException;
15
16 /**
17 * @author Kévin Dunglas <[email protected]>
18 */
19 #[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY)]
20 class MaxDepth
21 {
22 /**
23 * @param int $maxDepth The maximum serialization depth
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 }