Debian Codegraph @

lib/3rdParty/composer/symfony/serializer/Attribute/SerializedPath.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\PropertyAccess\Exception\InvalidPropertyPathException;
15 use Symfony\Component\PropertyAccess\PropertyPath;
16 use Symfony\Component\Serializer\Exception\InvalidArgumentException;
17
18 /**
19 * @author Tobias Bönner <[email protected]>
20 */
21 #[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY)]
22 class SerializedPath
23 {
24 public readonly PropertyPath $serializedPath;
25
26 /**
27 * @param string $serializedPath A path using a valid PropertyAccess syntax where the value is stored in a normalized representation
28 */
29 public function __construct(string $serializedPath)
30 {
31 try {
32 $this->serializedPath = new PropertyPath($serializedPath);
33 } catch (InvalidPropertyPathException) {
34 throw new InvalidArgumentException(\sprintf('Parameter given to "%s" must be a valid property path.', self::class));
35 }
36 }
37
38 #[\Deprecated('Use the "serializedPath" property instead', 'symfony/serializer:7.4')]
39 public function getSerializedPath(): PropertyPath
40 {
41 return $this->serializedPath;
42 }
43 }
44
45 if (!class_exists(\Symfony\Component\Serializer\Annotation\SerializedPath::class, false)) {
46 class_alias(SerializedPath::class, \Symfony\Component\Serializer\Annotation\SerializedPath::class);
47 }