Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[DependencyInjection][HttpKernel] Add PHPDoc to attribute classes and properties #51971

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::IS_REPEATABLE)]
final class AsAlias
{
/**
* @param string|null $id The id of the alias
* @param bool $public Whether to declare the alias public
*/
public function __construct(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@param should be used

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the whole PR πŸ‘

public ?string $id = null,
public bool $public = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,17 @@

use Symfony\Component\DependencyInjection\ContainerInterface;

/**
* Declares a decorating service.
*/
#[\Attribute(\Attribute::TARGET_CLASS)]
class AsDecorator
{
/**
* @param string $decorates The service id to decorate
* @param int $priority The priority of this decoration when multiple decorators are declared for the same service
* @param int $onInvalid The behavior to adopt when the decoration is invalid; must be one of the {@see ContainerInterface} constants
*/
public function __construct(
public string $decorates,
public int $priority = 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
#[\Attribute(\Attribute::TARGET_CLASS)]
class AsTaggedItem
{
/**
* @param string|null $index The property or method to use to index the item in the locator
* @param int|null $priority The priority of the item; the higher the number, the earlier the tagged service will be located in the locator
*/
public function __construct(
public ?string $index = null,
public ?int $priority = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@
#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::IS_REPEATABLE)]
class Autoconfigure
{
/**
* @param array<array-key, array<array-key, mixed>>|null $tags The tags to add to the service
* @param array<string, array<array-key, mixed>>|null $calls The calls to be made when instantiating the service
* @param array<string, mixed>|null $bind The bindings to declare for the service
* @param bool|string|null $lazy Whether the service is lazy-loaded
* @param bool|null $public Whether to declare the service as public
* @param bool|null $shared Whether to declare the service as shared
* @param bool|null $autowire Whether to declare the service as autowired
* @param array<string, mixed>|null $properties The properties to define when creating the service
* @param array<class-string, string>|string|null $configurator A PHP function, reference or an array containing a class/Reference and a method to call after the service is fully initialized
* @param string|null $constructor The public static method to use to instantiate the service
*/
public function __construct(
public ?array $tags = null,
public ?array $calls = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::IS_REPEATABLE)]
class AutoconfigureTag extends Autoconfigure
{
/**
* @param string|null $name The tag name to add
* @param array<array-key, mixed> $attributes The tag attributes to attach to the tag
*/
public function __construct(string $name = null, array $attributes = [])
{
parent::__construct(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
class AutowireCallable extends Autowire
{
/**
* @param bool|class-string $lazy Whether to use lazy-loading for this argument
* @param string|array|null $callable The callable to autowire
* @param string|null $service The service containing the callable to autowire
* @param string|null $method The method name that will be autowired
* @param bool|class-string $lazy Whether to use lazy-loading for this argument
*/
public function __construct(
string|array $callable = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@

namespace Symfony\Component\DependencyInjection\Attribute;

/**
* Autowires the inner object of decorating services.
*/
#[\Attribute(\Attribute::TARGET_PARAMETER)]
class AutowireDecorated
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,14 @@
class AutowireIterator extends Autowire
{
/**
* @param string|string[] $exclude A service or a list of services to exclude
* @see ServiceSubscriberInterface::getSubscribedServices()
*
* @param string $tag A tag name to search for to populate the iterator
* @param string|null $indexAttribute The name of the attribute that defines the key referencing each service in the tagged collection
* @param string|null $defaultIndexMethod The static method that should be called to get each service's key when their tag doesn't define the previous attribute
* @param string|null $defaultPriorityMethod The static method that should be called to get each service's priority when their tag doesn't define the "priority" attribute
* @param string|array<string> $exclude A service id or a list of service ids to exclude
* @param bool $excludeSelf Whether to automatically exclude the referencing service from the iterator
*/
public function __construct(
string $tag,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@ class AutowireLocator extends Autowire
/**
* @see ServiceSubscriberInterface::getSubscribedServices()
*
* @param string|array<string|SubscribedService> $services An explicit list of services or a tag name
* @param string|string[] $exclude A service or a list of services to exclude
* @param string|array<string|SubscribedService> $services A tag name or an explicit list of service ids
* @param string|null $indexAttribute The name of the attribute that defines the key referencing each service in the locator
* @param string|null $defaultIndexMethod The static method that should be called to get each service's key when their tag doesn't define the previous attribute
* @param string|null $defaultPriorityMethod The static method that should be called to get each service's priority when their tag doesn't define the "priority" attribute
* @param string|array $exclude A service id or a list of service ids to exclude
* @param bool $excludeSelf Whether to automatically exclude the referencing service from the locator
*/
public function __construct(
string|array $services,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
#[\Attribute(\Attribute::TARGET_PARAMETER)]
class AutowireServiceClosure extends Autowire
{
/**
* @param string $service The service id to wrap in the closure
*/
public function __construct(string $service)
{
parent::__construct(new ServiceClosureArgument(new Reference($service)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,20 @@

namespace Symfony\Component\DependencyInjection\Attribute;

/**
* Autowires an iterator of services based on a tag name.
*/
#[\Attribute(\Attribute::TARGET_PARAMETER)]
class TaggedIterator extends AutowireIterator
{
/**
* @param string $tag The tag to look for to populate the iterator
* @param string|null $indexAttribute The name of the attribute that defines the key referencing each service in the tagged collection
* @param string|null $defaultIndexMethod The static method that should be called to get each service's key when their tag doesn't define the previous attribute
* @param string|null $defaultPriorityMethod The static method that should be called to get each service's priority when their tag doesn't define the "priority" attribute
* @param string|string[] $exclude A service id or a list of service ids to exclude
* @param bool $excludeSelf Whether to automatically exclude the referencing service from the iterator
*/
public function __construct(
public string $tag,
public ?string $indexAttribute = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,20 @@

namespace Symfony\Component\DependencyInjection\Attribute;

/**
* Autowires a locator of services based on a tag name.
*/
#[\Attribute(\Attribute::TARGET_PARAMETER)]
class TaggedLocator extends AutowireLocator
{
/**
* @param string $tag The tag to look for to populate the locator
* @param string|null $indexAttribute The name of the attribute that defines the key referencing each service in the tagged collection
* @param string|null $defaultIndexMethod The static method that should be called to get each service's key when their tag doesn't define the previous attribute
* @param string|null $defaultPriorityMethod The static method that should be called to get each service's priority when their tag doesn't define the "priority" attribute
* @param string|string[] $exclude A service id or a list of service ids to exclude
* @param bool $excludeSelf Whether to automatically exclude the referencing service from the locator
*/
public function __construct(
public string $tag,
public ?string $indexAttribute = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@
#[\Attribute(\Attribute::TARGET_PARAMETER)]
final class Target
{
public function __construct(
public ?string $name = null,
) {
/**
* @param string|null $name The name of the target autowiring alias
*/
public function __construct(public ?string $name = null)
{
}

public function getParsedName(): string
Expand Down
8 changes: 5 additions & 3 deletions src/Symfony/Component/DependencyInjection/Attribute/When.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD | \Attribute::TARGET_FUNCTION | \Attribute::IS_REPEATABLE)]
class When
{
public function __construct(
public string $env,
) {
/**
* @param string $env The environment under which the class will be registered as a service (i.e. "dev", "test", "prod")
*/
public function __construct(public string $env)
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
#[\Attribute(\Attribute::TARGET_CLASS)]
class AsTargetedValueResolver
{
public function __construct(
public readonly ?string $name = null,
) {
/**
* @param string|null $name The name with which the resolver can be targeted
*/
public function __construct(public readonly ?string $name = null)
{
}
}
6 changes: 6 additions & 0 deletions src/Symfony/Component/HttpKernel/Attribute/MapDateTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,19 @@
namespace Symfony\Component\HttpKernel\Attribute;

use Symfony\Component\HttpKernel\Controller\ArgumentResolver\DateTimeValueResolver;
use Symfony\Component\HttpKernel\Controller\ValueResolverInterface;

/**
* Controller parameter tag to configure DateTime arguments.
*/
#[\Attribute(\Attribute::TARGET_PARAMETER)]
class MapDateTime extends ValueResolver
{
/**
* @param string|null $format The DateTime format to use, @see https://php.net/datetime.format
* @param bool $disabled Whether this value resolver is disabled; this allows to enable a value resolver globally while disabling it in specific cases
* @param class-string<ValueResolverInterface>|string $resolver The name of the resolver to use
*/
public function __construct(
public readonly ?string $format = null,
bool $disabled = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\Component\HttpKernel\Attribute;

use Symfony\Component\HttpKernel\Controller\ArgumentResolver\QueryParameterValueResolver;
use Symfony\Component\HttpKernel\Controller\ValueResolverInterface;

/**
* Can be used to pass a query parameter to a controller argument.
Expand All @@ -24,7 +25,11 @@ 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.
* @param string|null $name The name of the query parameter; if null, the name of the argument in the controller will be used
* @param (FILTER_VALIDATE_*)|(FILTER_SANITIZE_*)|null $filter The filter to pass to "filter_var()"
* @param int-mask-of<(FILTER_FLAG_*)|FILTER_NULL_ON_FAILURE> $flags The flags to pass to "filter_var()"
* @param array $options The options to pass to "filter_var()"
* @param class-string<ValueResolverInterface>|string $resolver The name of the resolver to use
*/
public function __construct(
public ?string $name = null,
Expand Down
6 changes: 6 additions & 0 deletions src/Symfony/Component/HttpKernel/Attribute/MapQueryString.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ class MapQueryString extends ValueResolver
{
public ArgumentMetadata $metadata;

/**
* @param array<string, mixed> $serializationContext The serialization context to use when deserializing the query string
* @param string|GroupSequence|array<string>|null $validationGroups The validation groups to use when validating the query string mapping
* @param class-string $resolver The class name of the resolver to use
* @param int $validationFailedStatusCode The HTTP code to return if the validation fails
*/
public function __construct(
public readonly array $serializationContext = [],
public readonly string|GroupSequence|array|null $validationGroups = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ class MapRequestPayload extends ValueResolver
{
public ArgumentMetadata $metadata;

/**
* @param array<string>|string|null $acceptFormat The payload formats to accept (i.e. "json", "xml")
* @param array<string, mixed> $serializationContext The serialization context to use when deserializing the payload
* @param string|GroupSequence|array<string>|null $validationGroups The validation groups to use when validating the query string mapping
* @param class-string $resolver The class name of the resolver to use
* @param int $validationFailedStatusCode The HTTP code to return if the validation fails
*/
public function __construct(
public readonly array|string|null $acceptFormat = null,
public readonly array $serializationContext = [],
Expand Down
6 changes: 5 additions & 1 deletion src/Symfony/Component/HttpKernel/Attribute/ValueResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@

use Symfony\Component\HttpKernel\Controller\ValueResolverInterface;

/**
* Defines which value resolver should be used for a given parameter.
*/
#[\Attribute(\Attribute::TARGET_PARAMETER | \Attribute::IS_REPEATABLE)]
class ValueResolver
{
/**
* @param class-string<ValueResolverInterface>|string $resolver
* @param class-string<ValueResolverInterface>|string $resolver The class name of the resolver to use
* @param bool $disabled Whether this value resolver is disabled; this allows to enable a value resolver globally while disabling it in specific cases
*/
public function __construct(
public string $resolver,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@
namespace Symfony\Component\HttpKernel\Attribute;

/**
* Defines the HTTP status code applied to an exception.
*
* @author Dejan Angelov <[email protected]>
*/
#[\Attribute(\Attribute::TARGET_CLASS)]
class WithHttpStatus
{
/**
* @param array<string, string> $headers
* @param int $statusCode The HTTP status code to use
* @param array<string, string> $headers The HTTP headers to add to the response
*/
public function __construct(
public readonly int $statusCode,
Expand Down
4 changes: 3 additions & 1 deletion src/Symfony/Component/HttpKernel/Attribute/WithLogLevel.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@
use Psr\Log\LogLevel;

/**
* Defines the log level applied to an exception.
*
* @author Dejan Angelov <[email protected]>
*/
#[\Attribute(\Attribute::TARGET_CLASS)]
final class WithLogLevel
{
/**
* @param LogLevel::* $level
* @param LogLevel::* $level The level to use to log the exception
*/
public function __construct(public readonly string $level)
{
Expand Down