Debian Codegraph @

lib/3rdParty/composer/symfony/serializer/Attribute/SerializedName.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 Fabien Bourigault <[email protected]>
18 */
19 #[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY)]
20 class SerializedName
21 {
22 /**
23 * @param string $serializedName The name of the property as it will be serialized
24 */
25 public function __construct(
26 public readonly string $serializedName,
27 ) {
28 if ('' === $serializedName) {
29 throw new InvalidArgumentException(\sprintf('Parameter given to "%s" must be a non-empty string.', self::class));
30 }
31 }
32
33 #[\Deprecated('Use the "serializedName" property instead', 'symfony/serializer:7.4')]
34 public function getSerializedName(): string
35 {
36 return $this->serializedName;
37 }
38 }
39
40 if (!class_exists(\Symfony\Component\Serializer\Annotation\SerializedName::class, false)) {
41 class_alias(SerializedName::class, \Symfony\Component\Serializer\Annotation\SerializedName::class);
42 }