Skip to content

Commit 74cced5

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

22 files changed

+257
-13
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,14 @@
2020
final class AsAlias
2121
{
2222
public function __construct(
23+
/**
24+
* The id of the service to alias.
25+
*/
2326
public ?string $id = null,
27+
28+
/**
29+
* Whether to declare the alias public.
30+
*/
2431
public bool $public = false,
2532
) {
2633
}

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,29 @@
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
{
1922
public function __construct(
23+
/**
24+
* The service id to decorate.
25+
*/
2026
public string $decorates,
27+
28+
/**
29+
* The priority of this decoration when multiple decorators are declared for the same service.
30+
*/
2131
public int $priority = 0,
32+
33+
/**
34+
* The behavior to adopt when the decoration is invalid. Must be one of
35+
* the {@see ContainerInterface} constants.
36+
*
37+
* @var ContainerInterface::*
38+
*/
2239
public int $onInvalid = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE,
2340
) {
2441
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,15 @@
2020
class AsTaggedItem
2121
{
2222
public function __construct(
23+
/**
24+
* The property or method to use to index the item in the locator.
25+
*/
2326
public ?string $index = null,
27+
28+
/**
29+
* The priority of the item. The higher the number, the earlier the tagged service
30+
* will be located in the locator.
31+
*/
2432
public ?int $priority = null,
2533
) {
2634
}

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

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,55 @@
2020
class Autoconfigure
2121
{
2222
public function __construct(
23+
/**
24+
* The tags to add to the service.
25+
*/
2326
public ?array $tags = null,
27+
28+
/**
29+
* The calls to be made when instantiating the service.
30+
*/
2431
public ?array $calls = null,
32+
33+
/**
34+
* The bindings to declare for the service.
35+
*/
2536
public ?array $bind = null,
37+
38+
/**
39+
* Whether the service is lazy-loaded.
40+
*/
2641
public bool|string|null $lazy = null,
42+
43+
/**
44+
* Whether to declare the service as public.
45+
*/
2746
public ?bool $public = null,
47+
48+
/**
49+
* Whether to declare the service as shared.
50+
*/
2851
public ?bool $shared = null,
52+
53+
/**
54+
* Whether to declare the service as autowired.
55+
*/
2956
public ?bool $autowire = null,
57+
58+
/**
59+
* The properties to define when creating the service.
60+
*/
3061
public ?array $properties = null,
62+
63+
/**
64+
* A PHP function, reference or an array containing a class/Reference and
65+
* a method to call after the service is fully initialized.
66+
*/
3167
public array|string|null $configurator = null,
68+
69+
/**
70+
* The public static inner method to use to instantiate the service.
71+
*/
3272
public string|null $constructor = null,
3373
) {
3474
}

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 to the tag
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 ids
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|array $exclude A service id or a list of services ids 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 ids
30+
* @param string|null $indexAttribute The name of the attribute that defines the key referencing each service in the locator
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|array $exclude A service id or a list of services ids to exclude
34+
* @param bool $excludeSelf Whether to automatically exclude the referencing service from the locator
3135
*/
3236
public function __construct(
3337
string|array $services,

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,12 @@
2020
#[\Attribute(\Attribute::TARGET_PARAMETER)]
2121
class AutowireServiceClosure extends Autowire
2222
{
23-
public function __construct(string $service)
24-
{
23+
public function __construct(
24+
/*
25+
* The service id to wrap in the closure.
26+
*/
27+
string $service
28+
) {
2529
parent::__construct(new ServiceClosureArgument(new Reference($service)));
2630
}
2731
}

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,44 @@
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
{
1720
public function __construct(
21+
/**
22+
* The tag to look for to populate the iterator.
23+
*/
1824
public string $tag,
25+
26+
/**
27+
* The name of the attribute that defines the key referencing each
28+
* service in the tagged collection.
29+
*/
1930
public ?string $indexAttribute = null,
31+
32+
/**
33+
* The static method that should be called to get each service's
34+
* key when their tag doesn't define the previous attribute.
35+
*/
2036
public ?string $defaultIndexMethod = null,
37+
38+
/**
39+
* The static method that should be called to get each service's
40+
* priority when their tag doesn't define the "priority" attribute.
41+
*/
2142
public ?string $defaultPriorityMethod = null,
43+
44+
/**
45+
* A service id or a list of services ids to exclude.
46+
*/
2247
public string|array $exclude = [],
48+
49+
/**
50+
* Whether to automatically exclude the referencing service from the iterator.
51+
*/
2352
public bool $excludeSelf = true,
2453
) {
2554
parent::__construct($tag, $indexAttribute, $defaultIndexMethod, $defaultPriorityMethod, $exclude, $excludeSelf);

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,44 @@
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
{
1720
public function __construct(
21+
/**
22+
* The tag to look for to populate the locator.
23+
*/
1824
public string $tag,
25+
26+
/**
27+
* The name of the attribute that defines the key referencing each
28+
* service in the tagged collection.
29+
*/
1930
public ?string $indexAttribute = null,
31+
32+
/**
33+
* The static method that should be called to get each service's
34+
* key when their tag doesn't define the previous attribute.
35+
*/
2036
public ?string $defaultIndexMethod = null,
37+
38+
/**
39+
* The static method that should be called to get each service's
40+
* priority when their tag doesn't define the "priority" attribute.
41+
*/
2142
public ?string $defaultPriorityMethod = null,
43+
44+
/**
45+
* A service id or a list of services ids to exclude.
46+
*/
2247
public string|array $exclude = [],
48+
49+
/**
50+
* Whether to automatically exclude the referencing service from the locator.
51+
*/
2352
public bool $excludeSelf = true,
2453
) {
2554
parent::__construct($tag, $indexAttribute, $defaultIndexMethod, $defaultPriorityMethod, $exclude, $excludeSelf);

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
final class Target
2424
{
2525
public function __construct(
26+
/**
27+
* The service alias to autowire.
28+
*/
2629
public ?string $name = null,
2730
) {
2831
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
class When
2121
{
2222
public function __construct(
23+
/**
24+
* The environment under which the class will be registered as a service (i.e. "dev", "test", "prod").
25+
*/
2326
public string $env,
2427
) {
2528
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
class AsTargetedValueResolver
1919
{
2020
public function __construct(
21+
/**
22+
* The name with which the resolver can be targeted.
23+
*/
2124
public readonly ?string $name = null,
2225
) {
2326
}

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,20 @@
1919
#[\Attribute(\Attribute::TARGET_PARAMETER)]
2020
class MapDateTime extends ValueResolver
2121
{
22+
/**
23+
* @param class-string $resolver The class name of the resolver to use
24+
*/
2225
public function __construct(
26+
/**
27+
* @see https://www.php.net/manual/en/datetime.format.php
28+
*
29+
* The DateTime format to use.
30+
*/
2331
public readonly ?string $format = null,
32+
33+
/**
34+
* Whether this value resolver is disabled.
35+
*/
2436
bool $disabled = false,
2537
string $resolver = DateTimeValueResolver::class,
2638
) {

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,27 @@ 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 class-string $resolver The class name of the resolver to use
2828
*/
2929
public function __construct(
30+
/**
31+
* The name of the query parameter. If null, the name of the argument in the controller will be used.
32+
*/
3033
public ?string $name = null,
34+
35+
/**
36+
* The filter to pass to "filter_var()".
37+
*/
3138
public ?int $filter = null,
39+
40+
/**
41+
* The flags to pass to "filter_var()".
42+
*/
3243
public int $flags = 0,
44+
45+
/**
46+
* The options to pass to "filter_var()".
47+
*/
3348
public array $options = [],
3449
string $resolver = QueryParameterValueResolver::class,
3550
) {

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

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

29+
/**
30+
* @param class-string $resolver The class name of the resolver to use
31+
*/
2932
public function __construct(
33+
/**
34+
* The serialization context to use when deserializing the query string.
35+
*/
3036
public readonly array $serializationContext = [],
37+
38+
/**
39+
* The validation groups to use when validating the query string mapping.
40+
*/
3141
public readonly string|GroupSequence|array|null $validationGroups = null,
3242
string $resolver = RequestPayloadValueResolver::class,
43+
44+
/**
45+
* The HTTP code to return if the validation fails.
46+
*/
3347
public readonly int $validationFailedStatusCode = Response::HTTP_NOT_FOUND,
3448
) {
3549
parent::__construct($resolver);

0 commit comments

Comments
 (0)