first commit

This commit is contained in:
Sampanna Rimal
2024-08-27 17:48:06 +05:45
commit 53c0140f58
10839 changed files with 1125847 additions and 0 deletions

View File

@ -0,0 +1,27 @@
<?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\HttpKernel\Attribute;
/**
* Autoconfigures controllers as services by applying
* the `controller.service_arguments` tag to them.
*
* This enables injecting services as method arguments in addition
* to other conventional dependency injection strategies.
*/
#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::TARGET_FUNCTION)]
class AsController
{
public function __construct()
{
}
}

View File

@ -0,0 +1,24 @@
<?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\HttpKernel\Attribute;
/**
* Service tag to autoconfigure targeted value resolvers.
*/
#[\Attribute(\Attribute::TARGET_CLASS)]
class AsTargetedValueResolver
{
public function __construct(
public readonly ?string $name = null,
) {
}
}

View File

@ -0,0 +1,107 @@
<?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\HttpKernel\Attribute;
/**
* Describes the default HTTP cache headers on controllers.
* Headers defined in the Cache attribute are ignored if they are already set
* by the controller.
*
* @see https://symfony.com/doc/current/http_cache.html#making-your-responses-http-cacheable
*
* @author Fabien Potencier <fabien@symfony.com>
*/
#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD | \Attribute::TARGET_FUNCTION)]
final class Cache
{
public function __construct(
/**
* The expiration date as a valid date for the strtotime() function.
*/
public ?string $expires = null,
/**
* The number of seconds that the response is considered fresh by a private
* cache like a web browser.
*/
public int|string|null $maxage = null,
/**
* The number of seconds that the response is considered fresh by a public
* cache like a reverse proxy cache.
*/
public int|string|null $smaxage = null,
/**
* If true, the contents will be stored in a public cache and served to all
* the next requests.
*/
public ?bool $public = null,
/**
* If true, the response is not served stale by a cache in any circumstance
* without first revalidating with the origin.
*/
public bool $mustRevalidate = false,
/**
* Set "Vary" header.
*
* Example:
* ['Accept-Encoding', 'User-Agent']
*
* @see https://symfony.com/doc/current/http_cache/cache_vary.html
*
* @var string[]
*/
public array $vary = [],
/**
* An expression to compute the Last-Modified HTTP header.
*
* The expression is evaluated by the ExpressionLanguage component, it
* receives all the request attributes and the resolved controller arguments.
*
* The result of the expression must be a DateTimeInterface.
*/
public ?string $lastModified = null,
/**
* An expression to compute the ETag HTTP header.
*
* The expression is evaluated by the ExpressionLanguage component, it
* receives all the request attributes and the resolved controller arguments.
*
* The result must be a string that will be hashed.
*/
public ?string $etag = null,
/**
* max-stale Cache-Control header
* It can be expressed in seconds or with a relative time format (1 day, 2 weeks, ...).
*/
public int|string|null $maxStale = null,
/**
* stale-while-revalidate Cache-Control header
* It can be expressed in seconds or with a relative time format (1 day, 2 weeks, ...).
*/
public int|string|null $staleWhileRevalidate = null,
/**
* stale-if-error Cache-Control header
* It can be expressed in seconds or with a relative time format (1 day, 2 weeks, ...).
*/
public int|string|null $staleIfError = null,
) {
}
}

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\HttpKernel\Attribute;
use Symfony\Component\HttpKernel\Controller\ArgumentResolver\DateTimeValueResolver;
/**
* Controller parameter tag to configure DateTime arguments.
*/
#[\Attribute(\Attribute::TARGET_PARAMETER)]
class MapDateTime extends ValueResolver
{
public function __construct(
public readonly ?string $format = null,
bool $disabled = false,
string $resolver = DateTimeValueResolver::class,
) {
parent::__construct($resolver, $disabled);
}
}

View File

@ -0,0 +1,38 @@
<?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\HttpKernel\Attribute;
use Symfony\Component\HttpKernel\Controller\ArgumentResolver\QueryParameterValueResolver;
/**
* Can be used to pass a query parameter to a controller argument.
*
* @author Ruud Kamphuis <ruud@ticketswap.com>
*/
#[\Attribute(\Attribute::TARGET_PARAMETER)]
final class MapQueryParameter extends ValueResolver
{
/**
* @see https://php.net/filter.filters.validate for filter, flags and options
*
* @param string|null $name The name of the query parameter. If null, the name of the argument in the controller will be used.
*/
public function __construct(
public ?string $name = null,
public ?int $filter = null,
public int $flags = 0,
public array $options = [],
string $resolver = QueryParameterValueResolver::class,
) {
parent::__construct($resolver);
}
}

View File

@ -0,0 +1,37 @@
<?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\HttpKernel\Attribute;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Controller\ArgumentResolver\RequestPayloadValueResolver;
use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata;
use Symfony\Component\Validator\Constraints\GroupSequence;
/**
* Controller parameter tag to map the query string of the request to typed object and validate it.
*
* @author Konstantin Myakshin <molodchick@gmail.com>
*/
#[\Attribute(\Attribute::TARGET_PARAMETER)]
class MapQueryString extends ValueResolver
{
public ArgumentMetadata $metadata;
public function __construct(
public readonly array $serializationContext = [],
public readonly string|GroupSequence|array|null $validationGroups = null,
string $resolver = RequestPayloadValueResolver::class,
public readonly int $validationFailedStatusCode = Response::HTTP_NOT_FOUND,
) {
parent::__construct($resolver);
}
}

View File

@ -0,0 +1,38 @@
<?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\HttpKernel\Attribute;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Controller\ArgumentResolver\RequestPayloadValueResolver;
use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata;
use Symfony\Component\Validator\Constraints\GroupSequence;
/**
* Controller parameter tag to map the request content to typed object and validate it.
*
* @author Konstantin Myakshin <molodchick@gmail.com>
*/
#[\Attribute(\Attribute::TARGET_PARAMETER)]
class MapRequestPayload extends ValueResolver
{
public ArgumentMetadata $metadata;
public function __construct(
public readonly array|string|null $acceptFormat = null,
public readonly array $serializationContext = [],
public readonly string|GroupSequence|array|null $validationGroups = null,
string $resolver = RequestPayloadValueResolver::class,
public readonly int $validationFailedStatusCode = Response::HTTP_UNPROCESSABLE_ENTITY,
) {
parent::__construct($resolver);
}
}

View File

@ -0,0 +1,27 @@
<?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\HttpKernel\Attribute;
use Symfony\Component\HttpKernel\Controller\ValueResolverInterface;
#[\Attribute(\Attribute::TARGET_PARAMETER | \Attribute::IS_REPEATABLE)]
class ValueResolver
{
/**
* @param class-string<ValueResolverInterface>|string $resolver
*/
public function __construct(
public string $resolver,
public bool $disabled = false,
) {
}
}

View File

@ -0,0 +1,28 @@
<?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\HttpKernel\Attribute;
/**
* @author Dejan Angelov <angelovdejan@protonmail.com>
*/
#[\Attribute(\Attribute::TARGET_CLASS)]
class WithHttpStatus
{
/**
* @param array<string, string> $headers
*/
public function __construct(
public readonly int $statusCode,
public readonly array $headers = [],
) {
}
}

View File

@ -0,0 +1,31 @@
<?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\HttpKernel\Attribute;
use Psr\Log\LogLevel;
/**
* @author Dejan Angelov <angelovdejan@protonmail.com>
*/
#[\Attribute(\Attribute::TARGET_CLASS)]
final class WithLogLevel
{
/**
* @param LogLevel::* $level
*/
public function __construct(public readonly string $level)
{
if (!\defined('Psr\Log\LogLevel::'.strtoupper($this->level))) {
throw new \InvalidArgumentException(sprintf('Invalid log level "%s".', $this->level));
}
}
}