Skip to content

Commit 0685c42

Browse files
minor #51974 [Console][EventDispatcher][Security][Serializer][Workflow] Add PHPDoc to attribute classes and properties (alexandre-daubois)
This PR was merged into the 7.1 branch. Discussion ---------- [Console][EventDispatcher][Security][Serializer][Workflow] Add PHPDoc to attribute classes and properties | Q | A | ------------- | --- | Branch? | 7.1 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | Part of #51920 | License | MIT One more round. :information_source: A first review of this kind is being done [here](#51971), I'll adjust this PR accordingly once done 🙂 Commits ------- 8a2ac5a [Console][EventDispatcher][Security][Serializer][Workflow] Add PHPDoc to attribute classes and properties
2 parents 8b2ddd0 + 8a2ac5a commit 0685c42

File tree

17 files changed

+110
-24
lines changed

17 files changed

+110
-24
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@
1717
#[\Attribute(\Attribute::TARGET_CLASS)]
1818
class AsCommand
1919
{
20+
/**
21+
* @param string $name The name of the command, used when calling it (i.e. "cache:clear")
22+
* @param string|null $description The description of the command, displayed with the help page
23+
* @param string[] $aliases The list of aliases of the command. The command will be executed when using one of them (i.e. "cache:clean")
24+
* @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
25+
*/
2026
public function __construct(
2127
public string $name,
2228
public ?string $description = null,

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@
1919
#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
2020
class AsEventListener
2121
{
22+
/**
23+
* @param string|null $event The event name to listen to
24+
* @param string|null $method The method to run when the listened event is triggered
25+
* @param int $priority The priority of this listener if several are declared for the same event
26+
* @param string|null $dispatcher The service id of the event dispatcher to listen to
27+
*/
2228
public function __construct(
2329
public ?string $event = null,
2430
public ?string $method = null,

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: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,38 +14,27 @@
1414
use Symfony\Component\ExpressionLanguage\Expression;
1515

1616
/**
17+
* Checks if user has permission to access to some resource using security roles and voters.
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)]
2024
final class IsGranted
2125
{
26+
/**
27+
* @param string|Expression $attribute The attribute that will be checked against a given authentication token and optional subject
28+
* @param array|string|Expression|null $subject An optional subject - e.g. the current object being voted on
29+
* @param string|null $message A custom message when access is not granted
30+
* @param int|null $statusCode If set, will throw HttpKernel's HttpException with the given $statusCode; if null, Security\Core's AccessDeniedException will be used
31+
* @param int|null $exceptionCode If set, will add the exception code to thrown exception
32+
*/
2233
public function __construct(
23-
/**
24-
* Sets the first argument that will be passed to isGranted().
25-
*/
2634
public string|Expression $attribute,
27-
28-
/**
29-
* Sets the second argument passed to isGranted().
30-
*
31-
* @var array<string|Expression>|string|Expression|null
32-
*/
3335
public array|string|Expression|null $subject = null,
34-
35-
/**
36-
* The message of the exception - has a nice default if not set.
37-
*/
3836
public ?string $message = null,
39-
40-
/**
41-
* If set, will throw HttpKernel's HttpException with the given $statusCode.
42-
* If null, Security\Core's AccessDeniedException will be used.
43-
*/
4437
public ?int $statusCode = null,
45-
46-
/**
47-
* If set, will add the exception code to thrown exception.
48-
*/
4938
public ?int $exceptionCode = null,
5039
) {
5140
}

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ class Context
2222
private array $groups;
2323

2424
/**
25-
* @param string|string[] $groups
25+
* @param array<string, mixed> $context The common context to use when serializing or deserializing
26+
* @param array<string, mixed> $normalizationContext The context to use when serializing
27+
* @param array<string, mixed> $denormalizationContext The context to use when deserializing
28+
* @param string|string[] $groups The groups to use when serializing or deserializing
2629
*
2730
* @throws InvalidArgumentException
2831
*/

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@
1919
#[\Attribute(\Attribute::TARGET_CLASS)]
2020
class DiscriminatorMap
2121
{
22+
/**
23+
* @param string $typeProperty The property holding the type discriminator
24+
* @param array<string, class-string> $mapping The mapping between types and classes (i.e. ['admin_user' => AdminUser::class])
25+
*
26+
* @throws InvalidArgumentException
27+
*/
2228
public function __construct(
2329
private readonly string $typeProperty,
2430
private readonly array $mapping,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Groups
2525
private readonly array $groups;
2626

2727
/**
28-
* @param string|string[] $groups
28+
* @param string|string[] $groups The groups to define on the attribute target
2929
*/
3030
public function __construct(string|array $groups)
3131
{

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY)]
2020
class MaxDepth
2121
{
22+
/**
23+
* @param int $maxDepth The maximum serialization depth
24+
*/
2225
public function __construct(private readonly int $maxDepth)
2326
{
2427
if ($maxDepth <= 0) {

src/Symfony/Component/Serializer/Attribute/SerializedName.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY)]
2020
class SerializedName
2121
{
22+
/**
23+
* @param string $serializedName The name of the property as it will be serialized
24+
*/
2225
public function __construct(private readonly string $serializedName)
2326
{
2427
if ('' === $serializedName) {

src/Symfony/Component/Serializer/Attribute/SerializedPath.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ class SerializedPath
2323
{
2424
private PropertyPath $serializedPath;
2525

26+
/**
27+
* @param string $serializedPath A path using a valid PropertyAccess syntax where the value is stored in a normalized representation
28+
*/
2629
public function __construct(string $serializedPath)
2730
{
2831
try {

0 commit comments

Comments
 (0)