Skip to content

Commit 0c28525

Browse files
[Console][EventDispatcher][Security][Serializer][Workflow] Add PHPDoc to attribute classes and properties
1 parent d6c8797 commit 0c28525

File tree

19 files changed

+160
-6
lines changed

19 files changed

+160
-6
lines changed

src/Symfony/Component/Console/Attribute/AsCommand.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,19 @@
1717
#[\Attribute(\Attribute::TARGET_CLASS)]
1818
class AsCommand
1919
{
20+
/**
21+
* @param string[] $aliases The list of aliases of the command. The command will be executed when using one of them (i.e. "cache:clean")
22+
* @param bool $hidden If true, the command won't be shown when listing all the available commands, but it can still be run as any other command
23+
*/
2024
public function __construct(
25+
/**
26+
* The name of the command, used when calling it (i.e. "cache:clear").
27+
*/
2128
public string $name,
29+
30+
/**
31+
* The description of the command, displayed with the help page.
32+
*/
2233
public ?string $description = null,
2334
array $aliases = [],
2435
bool $hidden = false,

src/Symfony/Component/EventDispatcher/Attribute/AsEventListener.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,26 @@
2020
class AsEventListener
2121
{
2222
public function __construct(
23+
/**
24+
* The event name to listen to.
25+
*/
2326
public ?string $event = null,
27+
28+
/**
29+
* The method to run when the listened event is triggered.
30+
*/
2431
public ?string $method = null,
32+
33+
/**
34+
* The priority of this listener if several are declared for the same event.
35+
* Listeners with the highest priority are called first.
36+
* Use the "debug:event-dispatcher" command to show priorities of other listeners.
37+
*/
2538
public int $priority = 0,
39+
40+
/**
41+
* The service id of the event dispatcher to listen to.
42+
*/
2643
public ?string $dispatcher = null,
2744
) {
2845
}

src/Symfony/Component/Security/Core/Validator/Constraints/UserPassword.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
/**
1717
* @Annotation
18+
*
1819
* @Target({"PROPERTY", "METHOD", "ANNOTATION"})
1920
*/
2021
#[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
@@ -29,6 +30,13 @@ class UserPassword extends Constraint
2930
public $message = 'This value should be the user\'s current password.';
3031
public $service = 'security.validator.user_password';
3132

33+
/**
34+
* @param array<array-key, mixed>|null $options Options passed to the validation constraint
35+
* @param string|null $message The message to display if this constraint raises a violation
36+
* @param string|null $service The service id to use to check the user current password
37+
* @param string[]|null $groups The groups on which this validation constraint applies (@see https://symfony.com/doc/current/validation/groups.html)
38+
* @param mixed $payload Arbitrary data passed to the constraint to make any additional checks in the constraint validator
39+
*/
3240
public function __construct(array $options = null, string $message = null, string $service = null, array $groups = null, mixed $payload = null)
3341
{
3442
parent::__construct($options, $groups, $payload);

src/Symfony/Component/Security/Http/Attribute/CurrentUser.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
#[\Attribute(\Attribute::TARGET_PARAMETER)]
2121
class CurrentUser extends ValueResolver
2222
{
23+
/**
24+
* @param bool $disabled Whether this value resolver is disabled, which allows to enable a value resolver globally while disabling it in specific cases
25+
* @param string $resolver The class name of the resolver to use
26+
*/
2327
public function __construct(bool $disabled = false, string $resolver = UserValueResolver::class)
2428
{
2529
parent::__construct($resolver, $disabled);

src/Symfony/Component/Security/Http/Attribute/IsGranted.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
use Symfony\Component\ExpressionLanguage\Expression;
1515

1616
/**
17+
* Checks if user has permission to access to some resource using security roles.
18+
*
19+
* @see https://symfony.com/doc/current/security.html#roles
20+
*
1721
* @author Ryan Weaver <ryan@knpuniversity.com>
1822
*/
1923
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD | \Attribute::TARGET_FUNCTION)]

src/Symfony/Component/Serializer/Annotation/Context.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@
1616
/**
1717
* Annotation class for @Context().
1818
*
19+
* An attribute to define a context during normalization and denormalization processes.
20+
*
1921
* @Annotation
22+
*
2023
* @NamedArgumentConstructor
24+
*
2125
* @Target({"PROPERTY", "METHOD"})
2226
*
2327
* @author Maxime Steinhausser <maxime.steinhausser@gmail.com>
@@ -28,13 +32,24 @@ class Context
2832
private array $groups;
2933

3034
/**
31-
* @param string|string[] $groups
35+
* @param string|string[] $groups The groups on which to apply the defined context
3236
*
3337
* @throws InvalidArgumentException
3438
*/
3539
public function __construct(
40+
/**
41+
* The context being used during any operation.
42+
*/
3643
private readonly array $context = [],
44+
45+
/**
46+
* The context being used during the normalization process.
47+
*/
3748
private readonly array $normalizationContext = [],
49+
50+
/**
51+
* The context being used during the denormalization process.
52+
*/
3853
private readonly array $denormalizationContext = [],
3954
string|array $groups = [],
4055
) {

src/Symfony/Component/Serializer/Annotation/DiscriminatorMap.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,13 @@
1616
/**
1717
* Annotation class for @DiscriminatorMap().
1818
*
19+
* An attribute to define a matching between a type discriminator and a class when dealing with
20+
* abstract classes and interfaces.
21+
*
1922
* @Annotation
23+
*
2024
* @NamedArgumentConstructor
25+
*
2126
* @Target({"CLASS"})
2227
*
2328
* @author Samuel Roze <samuel.roze@gmail.com>
@@ -26,7 +31,16 @@
2631
class DiscriminatorMap
2732
{
2833
public function __construct(
34+
/**
35+
* The property holding the type discriminator.
36+
*/
2937
private readonly string $typeProperty,
38+
39+
/**
40+
* The mapping between types and classes (i.e. ['admin_user' => AdminUser::class]).
41+
*
42+
* @var array<string, class-string>
43+
*/
3044
private readonly array $mapping,
3145
) {
3246
if (empty($typeProperty)) {

src/Symfony/Component/Serializer/Annotation/Groups.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@
1616
/**
1717
* Annotation class for @Groups().
1818
*
19+
* An attribute to define serialization groups on a method, a property or a class.
20+
*
1921
* @Annotation
22+
*
2023
* @NamedArgumentConstructor
24+
*
2125
* @Target({"PROPERTY", "METHOD", "CLASS"})
2226
*
2327
* @author Kévin Dunglas <dunglas@gmail.com>
@@ -31,7 +35,7 @@ class Groups
3135
private readonly array $groups;
3236

3337
/**
34-
* @param string|string[] $groups
38+
* @param string|string[] $groups The groups to define on the attribute target
3539
*/
3640
public function __construct(string|array $groups)
3741
{

src/Symfony/Component/Serializer/Annotation/Ignore.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414
/**
1515
* Annotation class for @Ignore().
1616
*
17+
* An attribute to declare a property or a method to ignore during the serialization process.
18+
*
1719
* @Annotation
20+
*
1821
* @Target({"PROPERTY", "METHOD"})
1922
*
2023
* @author Kévin Dunglas <dunglas@gmail.com>

src/Symfony/Component/Serializer/Annotation/MaxDepth.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,25 @@
1616
/**
1717
* Annotation class for @MaxDepth().
1818
*
19+
* An attribute to define the maximum serialization depth of the target.
20+
*
1921
* @Annotation
22+
*
2023
* @NamedArgumentConstructor
24+
*
2125
* @Target({"PROPERTY", "METHOD"})
2226
*
2327
* @author Kévin Dunglas <dunglas@gmail.com>
2428
*/
2529
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY)]
2630
class MaxDepth
2731
{
28-
public function __construct(private readonly int $maxDepth)
29-
{
32+
public function __construct(
33+
/**
34+
* The maximum serialization depth.
35+
*/
36+
private readonly int $maxDepth
37+
) {
3038
if ($maxDepth <= 0) {
3139
throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" must be a positive integer.', static::class));
3240
}

0 commit comments

Comments
 (0)