first commit

This commit is contained in:
2024-07-15 12:33:27 +02:00
commit ce50ae282b
22084 changed files with 2623791 additions and 0 deletions

View File

@@ -0,0 +1,77 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Serializer\Attribute;
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
/**
* Annotation class for @Context().
*
* @Annotation
* @NamedArgumentConstructor
* @Target({"PROPERTY", "METHOD"})
*
* @author Maxime Steinhausser <maxime.steinhausser@gmail.com>
*/
#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::TARGET_PROPERTY | \Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
class Context
{
private array $groups;
/**
* @param string|string[] $groups
*
* @throws InvalidArgumentException
*/
public function __construct(
private readonly array $context = [],
private readonly array $normalizationContext = [],
private readonly array $denormalizationContext = [],
string|array $groups = [],
) {
if (!$context && !$normalizationContext && !$denormalizationContext) {
throw new InvalidArgumentException(sprintf('At least one of the "context", "normalizationContext", or "denormalizationContext" options must be provided as a non-empty array to "%s".', static::class));
}
$this->groups = (array) $groups;
foreach ($this->groups as $group) {
if (!\is_string($group)) {
throw new InvalidArgumentException(sprintf('Parameter "groups" given to "%s" must be a string or an array of strings, "%s" given.', static::class, get_debug_type($group)));
}
}
}
public function getContext(): array
{
return $this->context;
}
public function getNormalizationContext(): array
{
return $this->normalizationContext;
}
public function getDenormalizationContext(): array
{
return $this->denormalizationContext;
}
public function getGroups(): array
{
return $this->groups;
}
}
if (!class_exists(\Symfony\Component\Serializer\Annotation\Context::class, false)) {
class_alias(Context::class, \Symfony\Component\Serializer\Annotation\Context::class);
}

View File

@@ -0,0 +1,54 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Serializer\Attribute;
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
/**
* Annotation class for @DiscriminatorMap().
*
* @Annotation
* @NamedArgumentConstructor
* @Target({"CLASS"})
*
* @author Samuel Roze <samuel.roze@gmail.com>
*/
#[\Attribute(\Attribute::TARGET_CLASS)]
class DiscriminatorMap
{
public function __construct(
private readonly string $typeProperty,
private readonly array $mapping,
) {
if (empty($typeProperty)) {
throw new InvalidArgumentException(sprintf('Parameter "typeProperty" given to "%s" cannot be empty.', static::class));
}
if (empty($mapping)) {
throw new InvalidArgumentException(sprintf('Parameter "mapping" given to "%s" cannot be empty.', static::class));
}
}
public function getTypeProperty(): string
{
return $this->typeProperty;
}
public function getMapping(): array
{
return $this->mapping;
}
}
if (!class_exists(\Symfony\Component\Serializer\Annotation\DiscriminatorMap::class, false)) {
class_alias(DiscriminatorMap::class, \Symfony\Component\Serializer\Annotation\DiscriminatorMap::class);
}

View File

@@ -0,0 +1,62 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Serializer\Attribute;
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
/**
* Annotation class for @Groups().
*
* @Annotation
* @NamedArgumentConstructor
* @Target({"PROPERTY", "METHOD", "CLASS"})
*
* @author Kévin Dunglas <dunglas@gmail.com>
*/
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY | \Attribute::TARGET_CLASS)]
class Groups
{
/**
* @var string[]
*/
private readonly array $groups;
/**
* @param string|string[] $groups
*/
public function __construct(string|array $groups)
{
$this->groups = (array) $groups;
if (!$this->groups) {
throw new InvalidArgumentException(sprintf('Parameter given to "%s" cannot be empty.', static::class));
}
foreach ($this->groups as $group) {
if (!\is_string($group) || '' === $group) {
throw new InvalidArgumentException(sprintf('Parameter given to "%s" must be a string or an array of non-empty strings.', static::class));
}
}
}
/**
* @return string[]
*/
public function getGroups(): array
{
return $this->groups;
}
}
if (!class_exists(\Symfony\Component\Serializer\Annotation\Groups::class, false)) {
class_alias(Groups::class, \Symfony\Component\Serializer\Annotation\Groups::class);
}

View File

@@ -0,0 +1,29 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Serializer\Attribute;
/**
* Annotation class for @Ignore().
*
* @Annotation
* @Target({"PROPERTY", "METHOD"})
*
* @author Kévin Dunglas <dunglas@gmail.com>
*/
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY)]
class Ignore
{
}
if (!class_exists(\Symfony\Component\Serializer\Annotation\Ignore::class, false)) {
class_alias(Ignore::class, \Symfony\Component\Serializer\Annotation\Ignore::class);
}

View File

@@ -0,0 +1,46 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Serializer\Attribute;
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
/**
* Annotation class for @MaxDepth().
*
* @Annotation
* @NamedArgumentConstructor
* @Target({"PROPERTY", "METHOD"})
*
* @author Kévin Dunglas <dunglas@gmail.com>
*/
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY)]
class MaxDepth
{
public function __construct(private readonly int $maxDepth)
{
if ($maxDepth <= 0) {
throw new InvalidArgumentException(sprintf('Parameter given to "%s" must be a positive integer.', static::class));
}
}
/**
* @return int
*/
public function getMaxDepth()
{
return $this->maxDepth;
}
}
if (!class_exists(\Symfony\Component\Serializer\Annotation\MaxDepth::class, false)) {
class_alias(MaxDepth::class, \Symfony\Component\Serializer\Annotation\MaxDepth::class);
}

View File

@@ -0,0 +1,43 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Serializer\Attribute;
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
/**
* Annotation class for @SerializedName().
*
* @Annotation
* @NamedArgumentConstructor
* @Target({"PROPERTY", "METHOD"})
*
* @author Fabien Bourigault <bourigaultfabien@gmail.com>
*/
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY)]
class SerializedName
{
public function __construct(private readonly string $serializedName)
{
if ('' === $serializedName) {
throw new InvalidArgumentException(sprintf('Parameter given to "%s" must be a non-empty string.', self::class));
}
}
public function getSerializedName(): string
{
return $this->serializedName;
}
}
if (!class_exists(\Symfony\Component\Serializer\Annotation\SerializedName::class, false)) {
class_alias(SerializedName::class, \Symfony\Component\Serializer\Annotation\SerializedName::class);
}

View File

@@ -0,0 +1,49 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Serializer\Attribute;
use Symfony\Component\PropertyAccess\Exception\InvalidPropertyPathException;
use Symfony\Component\PropertyAccess\PropertyPath;
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
/**
* Annotation class for @SerializedPath().
*
* @Annotation
* @NamedArgumentConstructor
* @Target({"PROPERTY", "METHOD"})
*
* @author Tobias Bönner <tobi@boenner.family>
*/
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY)]
class SerializedPath
{
private PropertyPath $serializedPath;
public function __construct(string $serializedPath)
{
try {
$this->serializedPath = new PropertyPath($serializedPath);
} catch (InvalidPropertyPathException $pathException) {
throw new InvalidArgumentException(sprintf('Parameter given to "%s" must be a valid property path.', self::class));
}
}
public function getSerializedPath(): PropertyPath
{
return $this->serializedPath;
}
}
if (!class_exists(\Symfony\Component\Serializer\Annotation\SerializedPath::class, false)) {
class_alias(SerializedPath::class, \Symfony\Component\Serializer\Annotation\SerializedPath::class);
}