Skip to content

Commit 093bd61

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

22 files changed

+325
-21
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@
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+
* Whether to declare the alias public.
29+
*/
2430
public bool $public = false,
2531
) {
2632
}

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,27 @@
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+
*/
2237
public int $onInvalid = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE,
2338
) {
2439
}

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: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,16 @@
1919
#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::IS_REPEATABLE)]
2020
class AutoconfigureTag extends Autoconfigure
2121
{
22-
public function __construct(string $name = null, array $attributes = [])
22+
public function __construct(
23+
/*
24+
* The tag name to add.
25+
*/
26+
string $name = null,
27+
28+
/*
29+
* The tag attributes to attach to the tag.
30+
*/
31+
array $attributes = [])
2332
{
2433
parent::__construct(
2534
tags: [

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,24 @@ class AutowireCallable extends Autowire
2525
* @param bool|class-string $lazy Whether to use lazy-loading for this argument
2626
*/
2727
public function __construct(
28+
/*
29+
* The callable to autowire.
30+
*/
2831
string|array $callable = null,
32+
33+
/*
34+
* The service containing the callable to autowire.
35+
*/
2936
string $service = null,
37+
38+
/*
39+
* The method name that will be autowired.
40+
*/
3041
string $method = null,
42+
43+
/*
44+
* Whether to use lazy-loading for this argument.
45+
*/
3146
bool|string $lazy = false,
3247
) {
3348
if (!(null !== $callable xor null !== $service)) {

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: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,40 @@ 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
3332
*/
3433
public function __construct(
34+
/*
35+
* A tag name or an explicit list of services ids.
36+
*/
3537
string|array $services,
38+
39+
/*
40+
* The name of the attribute that defines the key referencing each
41+
* service in the tagged collection.
42+
*/
3643
string $indexAttribute = null,
44+
45+
/*
46+
* The static method that should be called to get each service's
47+
* key when their tag doesn't define the previous attribute.
48+
*/
3749
string $defaultIndexMethod = null,
50+
51+
/*
52+
* The static method that should be called to get each service's
53+
* priority when their tag doesn't define the "priority" attribute.
54+
*/
3855
string $defaultPriorityMethod = null,
56+
57+
/*
58+
* A service id or a list of services ids to exclude.
59+
*/
3960
string|array $exclude = [],
61+
62+
/*
63+
* Whether to automatically exclude the referencing service from the iterator.
64+
*/
4065
bool $excludeSelf = true,
4166
) {
4267
if (\is_string($services)) {

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

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,40 @@ 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
3130
*/
3231
public function __construct(
32+
/*
33+
* A tag name or an explicit list of services ids.
34+
*/
3335
string|array $services,
36+
37+
/*
38+
* The name of the attribute that defines the key referencing each
39+
* service in the tagged collection.
40+
*/
3441
string $indexAttribute = null,
42+
43+
/*
44+
* The static method that should be called to get each service's
45+
* key when their tag doesn't define the previous attribute.
46+
*/
3547
string $defaultIndexMethod = null,
48+
49+
/*
50+
* The static method that should be called to get each service's
51+
* priority when their tag doesn't define the "priority" attribute.
52+
*/
3653
string $defaultPriorityMethod = null,
54+
55+
/*
56+
* A service id or a list of services ids to exclude.
57+
*/
3758
string|array $exclude = [],
59+
60+
/*
61+
* Whether to automatically exclude the referencing service from the locator.
62+
*/
3863
bool $excludeSelf = true,
3964
) {
4065
$iterator = (new AutowireIterator($services, $indexAttribute, $defaultIndexMethod, $defaultPriorityMethod, (array) $exclude, $excludeSelf))->value;

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: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,45 @@
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,
19-
public ?string $indexAttribute = null,
20-
public ?string $defaultIndexMethod = null,
21-
public ?string $defaultPriorityMethod = null,
22-
public string|array $exclude = [],
23-
public bool $excludeSelf = true,
25+
26+
/*
27+
* The name of the attribute that defines the key referencing each
28+
* service in the tagged collection.
29+
*/
30+
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+
*/
36+
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+
*/
42+
string $defaultPriorityMethod = null,
43+
44+
/*
45+
* A service id or a list of services ids to exclude.
46+
*/
47+
string|array $exclude = [],
48+
49+
/*
50+
* Whether to automatically exclude the referencing service from the iterator.
51+
*/
52+
bool $excludeSelf = true,
2453
) {
2554
parent::__construct($tag, $indexAttribute, $defaultIndexMethod, $defaultPriorityMethod, $exclude, $excludeSelf);
2655
}

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

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,45 @@
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,
19-
public ?string $indexAttribute = null,
20-
public ?string $defaultIndexMethod = null,
21-
public ?string $defaultPriorityMethod = null,
22-
public string|array $exclude = [],
23-
public bool $excludeSelf = true,
25+
26+
/*
27+
* The name of the attribute that defines the key referencing each
28+
* service in the tagged collection.
29+
*/
30+
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+
*/
36+
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+
*/
42+
string $defaultPriorityMethod = null,
43+
44+
/*
45+
* A service id or a list of services ids to exclude.
46+
*/
47+
string|array $exclude = [],
48+
49+
/*
50+
* Whether to automatically exclude the referencing service from the locator.
51+
*/
52+
bool $excludeSelf = true,
2453
) {
2554
parent::__construct($tag, $indexAttribute, $defaultIndexMethod, $defaultPriorityMethod, $exclude, $excludeSelf);
2655
}

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", "staging", "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 by which the resolver can be targeted.
23+
*/
2124
public readonly ?string $name = null,
2225
) {
2326
}

0 commit comments

Comments
 (0)