Skip to content

Commit 5611f41

Browse files
[DependencyInjection][HttpKernel] Add PHPDoc to attribute classes and properties
1 parent 825ae03 commit 5611f41

22 files changed

+284
-10
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 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: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,65 @@
2020
class Autoconfigure
2121
{
2222
public function __construct(
23+
/**
24+
* The tags to add to the service.
25+
*
26+
* @var array<array-key, array<array-key, mixed>>
27+
*/
2328
public ?array $tags = null,
29+
30+
/**
31+
* The calls to be made when instantiating the service.
32+
*
33+
* @var array<string, array<array-key, mixed>>
34+
*/
2435
public ?array $calls = null,
36+
37+
/**
38+
* The bindings to declare for the service.
39+
*
40+
* @var array<string, mixed>
41+
*/
2542
public ?array $bind = null,
43+
44+
/**
45+
* Whether the service is lazy-loaded.
46+
*/
2647
public bool|string|null $lazy = null,
48+
49+
/**
50+
* Whether to declare the service as public.
51+
*/
2752
public ?bool $public = null,
53+
54+
/**
55+
* Whether to declare the service as shared.
56+
*/
2857
public ?bool $shared = null,
58+
59+
/**
60+
* Whether to declare the service as autowired.
61+
*/
2962
public ?bool $autowire = null,
63+
64+
/**
65+
* The properties to define when creating the service.
66+
*
67+
* @var array<string, mixed>
68+
*/
3069
public ?array $properties = null,
70+
71+
/**
72+
* A PHP function, reference or an array containing a class/Reference and
73+
* a method to call after the service is fully initialized.
74+
*
75+
* @var array<class-string, string>|string|null
76+
*/
3177
public array|string|null $configurator = null,
78+
79+
/**
80+
* The public static inner method to use to instantiate the service.
81+
*/
3282
public string|null $constructor = null,
3383
) {
3484
}

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<array-key, mixed> $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: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,14 @@
2020
class AutowireIterator extends Autowire
2121
{
2222
/**
23-
* @param string|string[] $exclude A service or a list of services to exclude
23+
* @see ServiceSubscriberInterface::getSubscribedServices()
24+
*
25+
* @param string $tag A tag name to search for to populate the iterator
26+
* @param string|null $indexAttribute The name of the attribute that defines the key referencing each service in the tagged collection
27+
* @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
28+
* @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
29+
* @param string|array<string> $exclude A service id or a list of service ids to exclude
30+
* @param bool $excludeSelf Whether to automatically exclude the referencing service from the iterator
2431
*/
2532
public function __construct(
2633
string $tag,

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,12 @@ class AutowireLocator extends Autowire
2828
/**
2929
* @see ServiceSubscriberInterface::getSubscribedServices()
3030
*
31-
* @param string|array<string|SubscribedService> $services An explicit list of services or a tag name
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 service ids
32+
* @param string|null $indexAttribute The name of the attribute that defines the key referencing each service in the locator
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 service ids to exclude
36+
* @param bool $excludeSelf Whether to automatically exclude the referencing service from the locator
3337
*/
3438
public function __construct(
3539
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: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,46 @@
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 service ids to exclude.
46+
*
47+
* @var string|array<string>
48+
*/
2249
public string|array $exclude = [],
50+
51+
/**
52+
* Whether to automatically exclude the referencing service from the iterator.
53+
*/
2354
public bool $excludeSelf = true,
2455
) {
2556
parent::__construct($tag, $indexAttribute, $defaultIndexMethod, $defaultPriorityMethod, $exclude, $excludeSelf);

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,46 @@
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 service ids to exclude.
46+
*
47+
* @var string|array<string>
48+
*/
2249
public string|array $exclude = [],
50+
51+
/**
52+
* Whether to automatically exclude the referencing service from the locator.
53+
*/
2354
public bool $excludeSelf = true,
2455
) {
2556
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: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,16 @@
1919
#[\Attribute(\Attribute::TARGET_PARAMETER)]
2020
class MapDateTime extends ValueResolver
2121
{
22+
/**
23+
* @param bool $disabled Whether this value resolver is disabled. This allows to enable a value resolver globally while disabling it in specific cases.
24+
* @param class-string $resolver The class name of the resolver to use
25+
*/
2226
public function __construct(
27+
/**
28+
* @see https://www.php.net/manual/en/datetime.format.php
29+
*
30+
* The DateTime format to use.
31+
*/
2332
public readonly ?string $format = null,
2433
bool $disabled = false,
2534
string $resolver = DateTimeValueResolver::class,

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

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,31 @@ 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+
*
38+
* @var FILTER_VALIDATE_*|FILTER_SANITIZE_*|null
39+
*/
3140
public ?int $filter = null,
41+
42+
/**
43+
* The flags to pass to "filter_var()".
44+
*
45+
* @var int-mask-of<FILTER_FLAG_*|FILTER_NULL_ON_FAILURE>
46+
*/
3247
public int $flags = 0,
48+
49+
/**
50+
* The options to pass to "filter_var()".
51+
*/
3352
public array $options = [],
3453
string $resolver = QueryParameterValueResolver::class,
3554
) {

0 commit comments

Comments
 (0)