Skip to content

Commit 7224e66

Browse files
[DependencyInjection][HttpKernel] Add PHPDoc to attribute classes and properties
1 parent f9a64ee commit 7224e66

22 files changed

+120
-9
lines changed

src/Symfony/Component/DependencyInjection/Attribute/AsAlias.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::IS_REPEATABLE)]
2020
final class AsAlias
2121
{
22+
/**
23+
* @param string|null $id The id of the service to alias
24+
* @param bool $public Whether to declare the alias public
25+
*/
2226
public function __construct(
2327
public ?string $id = null,
2428
public bool $public = false,

src/Symfony/Component/DependencyInjection/Attribute/AsDecorator.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,17 @@
1313

1414
use Symfony\Component\DependencyInjection\ContainerInterface;
1515

16+
/**
17+
* An attribute to declare a decorating service.
18+
*/
1619
#[\Attribute(\Attribute::TARGET_CLASS)]
1720
class AsDecorator
1821
{
22+
/**
23+
* @param string $decorates The service id to decorate
24+
* @param int $priority The priority of this decoration when multiple decorators are declared for the same service
25+
* @param int $onInvalid The behavior to adopt when the decoration is invalid. Must be one of the {@see ContainerInterface} constants
26+
*/
1927
public function __construct(
2028
public string $decorates,
2129
public int $priority = 0,

src/Symfony/Component/DependencyInjection/Attribute/AsTaggedItem.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
#[\Attribute(\Attribute::TARGET_CLASS)]
2020
class AsTaggedItem
2121
{
22+
/**
23+
* @param string|null $index The property or method to use to index the item in the locator
24+
* @param int|null $priority The priority of the item. The higher the number, the earlier the tagged service will be located in the locator
25+
*/
2226
public function __construct(
2327
public ?string $index = null,
2428
public ?int $priority = null,

src/Symfony/Component/DependencyInjection/Attribute/Autoconfigure.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,18 @@
1919
#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::IS_REPEATABLE)]
2020
class Autoconfigure
2121
{
22+
/**
23+
* @param array|null $tags The tags to add to the service
24+
* @param array|null $calls The calls to be made when instantiating the service
25+
* @param array|null $bind The bindings to declare for the service
26+
* @param bool|string|null $lazy Whether the service is lazy-loaded
27+
* @param bool|null $public Whether to declare the service as public
28+
* @param bool|null $shared Whether to declare the service as shared
29+
* @param bool|null $autowire Whether to declare the service as autowired
30+
* @param array|null $properties The properties to define when creating the service
31+
* @param array|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
32+
* @param string|null $constructor The public static inner method to use to instantiate the service
33+
*/
2234
public function __construct(
2335
public ?array $tags = null,
2436
public ?array $calls = null,

src/Symfony/Component/DependencyInjection/Attribute/AutoconfigureTag.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::IS_REPEATABLE)]
2020
class AutoconfigureTag extends Autoconfigure
2121
{
22+
/**
23+
* @param string|null $name The tag name to add
24+
* @param array $attributes The tag attributes to attach
25+
*/
2226
public function __construct(string $name = null, array $attributes = [])
2327
{
2428
parent::__construct(

src/Symfony/Component/DependencyInjection/Attribute/AutowireCallable.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@
2222
class AutowireCallable extends Autowire
2323
{
2424
/**
25-
* @param bool|class-string $lazy Whether to use lazy-loading for this argument
25+
* @param string|array|null $callable The callable to autowire
26+
* @param string|null $service The service containing the callable to autowire
27+
* @param string|null $method The method name that will be autowired
28+
* @param bool|class-string $lazy Whether to use lazy-loading for this argument
2629
*/
2730
public function __construct(
2831
string|array $callable = null,

src/Symfony/Component/DependencyInjection/Attribute/AutowireDecorated.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111

1212
namespace Symfony\Component\DependencyInjection\Attribute;
1313

14+
/**
15+
* An attribute to autowire the inner object of decorating services.
16+
*/
1417
#[\Attribute(\Attribute::TARGET_PARAMETER)]
1518
class AutowireDecorated
1619
{

src/Symfony/Component/DependencyInjection/Attribute/AutowireIterator.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,12 @@ class AutowireIterator extends Autowire
2828
/**
2929
* @see ServiceSubscriberInterface::getSubscribedServices()
3030
*
31-
* @param string|array<string|SubscribedService> $services A tag name or an explicit list of services
32-
* @param string|string[] $exclude A service or a list of services to exclude
31+
* @param string|array<string|SubscribedService> $services A tag name or an explicit list of services
32+
* @param string|null $indexAttribute The name of the attribute that defines the key referencing each service in the tagged collection
33+
* @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
34+
* @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
35+
* @param string|string[] $exclude A service or a list of services to exclude
36+
* @param bool $excludeSelf Whether to automatically exclude the referencing service from the iterator
3337
*/
3438
public function __construct(
3539
string|array $services,

src/Symfony/Component/DependencyInjection/Attribute/AutowireLocator.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,12 @@ class AutowireLocator extends Autowire
2626
/**
2727
* @see ServiceSubscriberInterface::getSubscribedServices()
2828
*
29-
* @param string|array<string|SubscribedService> $services An explicit list of services or a tag name
30-
* @param string|string[] $exclude A service or a list of services to exclude
29+
* @param string|array<string|SubscribedService> $services A tag name or an explicit list of services
30+
* @param string|null $indexAttribute The name of the attribute that defines the key referencing each service in the tagged collection
31+
* @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
32+
* @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
33+
* @param string|string[] $exclude A service or a list of services to exclude
34+
* @param bool $excludeSelf Whether to automatically exclude the referencing service from the iterator
3135
*/
3236
public function __construct(
3337
string|array $services,

src/Symfony/Component/DependencyInjection/Attribute/AutowireServiceClosure.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
#[\Attribute(\Attribute::TARGET_PARAMETER)]
2121
class AutowireServiceClosure extends Autowire
2222
{
23+
/**
24+
* @param string $service The service id to wrap in the closure
25+
*/
2326
public function __construct(string $service)
2427
{
2528
parent::__construct(new ServiceClosureArgument(new Reference($service)));

src/Symfony/Component/DependencyInjection/Attribute/TaggedIterator.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,20 @@
1111

1212
namespace Symfony\Component\DependencyInjection\Attribute;
1313

14+
/**
15+
* Autowires an iterator of services based on a tag name.
16+
*/
1417
#[\Attribute(\Attribute::TARGET_PARAMETER)]
1518
class TaggedIterator extends AutowireIterator
1619
{
20+
/**
21+
* @param string $tag The tag to look for to populate the iterator
22+
* @param string|null $indexAttribute The name of the attribute that defines the key referencing each service in the tagged collection
23+
* @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
24+
* @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
25+
* @param string|string[] $exclude A service or a list of services to exclude
26+
* @param bool $excludeSelf Whether to automatically exclude the referencing service from the iterator
27+
*/
1728
public function __construct(
1829
public string $tag,
1930
public ?string $indexAttribute = null,

src/Symfony/Component/DependencyInjection/Attribute/TaggedLocator.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,20 @@
1111

1212
namespace Symfony\Component\DependencyInjection\Attribute;
1313

14+
/**
15+
* Autowires a locator of services based on a tag name.
16+
*/
1417
#[\Attribute(\Attribute::TARGET_PARAMETER)]
1518
class TaggedLocator extends AutowireLocator
1619
{
20+
/**
21+
* @param string $tag The tag to look for to populate the locator
22+
* @param string|null $indexAttribute The name of the attribute that defines the key referencing each service in the tagged collection
23+
* @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
24+
* @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
25+
* @param string|string[] $exclude A service or a list of services to exclude
26+
* @param bool $excludeSelf Whether to automatically exclude the referencing service from the iterator
27+
*/
1728
public function __construct(
1829
public string $tag,
1930
public ?string $indexAttribute = null,

src/Symfony/Component/DependencyInjection/Attribute/Target.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
#[\Attribute(\Attribute::TARGET_PARAMETER)]
2323
final class Target
2424
{
25+
/**
26+
* @param string|null $name The service alias to autowire
27+
*/
2528
public function __construct(
2629
public ?string $name = null,
2730
) {

src/Symfony/Component/DependencyInjection/Attribute/When.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD | \Attribute::TARGET_FUNCTION | \Attribute::IS_REPEATABLE)]
2020
class When
2121
{
22+
/**
23+
* @param string $env The environment under which the class will be registered as a service
24+
*/
2225
public function __construct(
2326
public string $env,
2427
) {

src/Symfony/Component/HttpKernel/Attribute/AsTargetedValueResolver.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
#[\Attribute(\Attribute::TARGET_CLASS)]
1818
class AsTargetedValueResolver
1919
{
20+
/**
21+
* @param string|null $name The name by which the resolver can be targeted
22+
*/
2023
public function __construct(
2124
public readonly ?string $name = null,
2225
) {

src/Symfony/Component/HttpKernel/Attribute/MapDateTime.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
#[\Attribute(\Attribute::TARGET_PARAMETER)]
2020
class MapDateTime extends ValueResolver
2121
{
22+
/**
23+
* @param string|null $format The DateTime format to use
24+
* @param bool $disabled Whether this value resolver is disabled
25+
* @param string $resolver The class name of the resolver to use
26+
*/
2227
public function __construct(
2328
public readonly ?string $format = null,
2429
bool $disabled = false,

src/Symfony/Component/HttpKernel/Attribute/MapQueryParameter.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ final class MapQueryParameter extends ValueResolver
2424
/**
2525
* @see https://php.net/filter.filters.validate for filter, flags and options
2626
*
27-
* @param string|null $name The name of the query parameter. If null, the name of the argument in the controller will be used.
27+
* @param string|null $name The name of the query parameter. If null, the name of the argument in the controller will be used.
28+
* @param int|null $filter The filter to pass to "filter_var()"
29+
* @param int $flags The flags to pass to "filter_var()"
30+
* @param array $options The options to pass to "filter_var()"
31+
* @param string $resolver The class name of the resolver to use
2832
*/
2933
public function __construct(
3034
public ?string $name = null,

src/Symfony/Component/HttpKernel/Attribute/MapQueryString.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ class MapQueryString extends ValueResolver
2626
{
2727
public ArgumentMetadata $metadata;
2828

29+
/**
30+
* @param array $serializationContext The serialization context to use when deserializing the query string
31+
* @param string|GroupSequence|array|null $validationGroups The validation groups to use when validating the query string mapping
32+
* @param string $resolver The class name of the resolver to use
33+
* @param int $validationFailedStatusCode The HTTP code to return if the validation fails
34+
*/
2935
public function __construct(
3036
public readonly array $serializationContext = [],
3137
public readonly string|GroupSequence|array|null $validationGroups = null,

src/Symfony/Component/HttpKernel/Attribute/MapRequestPayload.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ class MapRequestPayload extends ValueResolver
2626
{
2727
public ArgumentMetadata $metadata;
2828

29+
/**
30+
* @param array|string|null $acceptFormat The payload formats to accept
31+
* @param array $serializationContext The serialization context to use when deserializing the payload
32+
* @param string|GroupSequence|array|null $validationGroups The validation groups to use when validating the query string mapping
33+
* @param string $resolver The class name of the resolver to use
34+
* @param int $validationFailedStatusCode The HTTP code to return if the validation fails
35+
*/
2936
public function __construct(
3037
public readonly array|string|null $acceptFormat = null,
3138
public readonly array $serializationContext = [],

src/Symfony/Component/HttpKernel/Attribute/ValueResolver.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,15 @@
1313

1414
use Symfony\Component\HttpKernel\Controller\ValueResolverInterface;
1515

16+
/**
17+
* An attribute to tell which value resolver should be used for a given parameter.
18+
*/
1619
#[\Attribute(\Attribute::TARGET_PARAMETER | \Attribute::IS_REPEATABLE)]
1720
class ValueResolver
1821
{
1922
/**
20-
* @param class-string<ValueResolverInterface>|string $resolver
23+
* @param class-string<ValueResolverInterface>|string $resolver The class name of the resolver to use
24+
* @param bool $disabled Whether this value resolver is disabled
2125
*/
2226
public function __construct(
2327
public string $resolver,

src/Symfony/Component/HttpKernel/Attribute/WithHttpStatus.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,16 @@
1212
namespace Symfony\Component\HttpKernel\Attribute;
1313

1414
/**
15+
* An attribute to define the HTTP status code applied to an exception
16+
*
1517
* @author Dejan Angelov <angelovdejan@protonmail.com>
1618
*/
1719
#[\Attribute(\Attribute::TARGET_CLASS)]
1820
class WithHttpStatus
1921
{
2022
/**
21-
* @param array<string, string> $headers
23+
* @param int $statusCode The HTTP status code to use
24+
* @param array<string, string> $headers The HTTP headers to add to the response
2225
*/
2326
public function __construct(
2427
public readonly int $statusCode,

src/Symfony/Component/HttpKernel/Attribute/WithLogLevel.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@
1414
use Psr\Log\LogLevel;
1515

1616
/**
17+
* An attribute to define the log level applied to an exception
18+
*
1719
* @author Dejan Angelov <angelovdejan@protonmail.com>
1820
*/
1921
#[\Attribute(\Attribute::TARGET_CLASS)]
2022
final class WithLogLevel
2123
{
2224
/**
23-
* @param LogLevel::* $level
25+
* @param LogLevel::* $level The level to use to log the exception
2426
*/
2527
public function __construct(public readonly string $level)
2628
{

0 commit comments

Comments
 (0)