Skip to content

[Routing] Extend old Annotations from new Attributes #52544

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Symfony/Component/Routing/Annotation/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class_exists(\Symfony\Component\Routing\Attribute\Route::class);

if (false) {
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD)]
class Route
class Route extends \Symfony\Component\Routing\Attribute\Route
{
}
}
2 changes: 2 additions & 0 deletions src/Symfony/Component/Routing/Attribute/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Alexander M. Turek <me@derrabus.de>
*
* @final since Symfony 6.4
*/
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD)]
class Route
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Serializer/Annotation/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class_exists(\Symfony\Component\Serializer\Attribute\Context::class);

if (false) {
#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::TARGET_PROPERTY | \Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
class Context
class Context extends \Symfony\Component\Serializer\Attribute\Context
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class_exists(\Symfony\Component\Serializer\Attribute\DiscriminatorMap::class);

if (false) {
#[\Attribute(\Attribute::TARGET_CLASS)]
class DiscriminatorMap
class DiscriminatorMap extends \Symfony\Component\Serializer\Attribute\DiscriminatorMap
{
}
}
2 changes: 1 addition & 1 deletion src/Symfony/Component/Serializer/Annotation/Groups.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class_exists(\Symfony\Component\Serializer\Attribute\Groups::class);

if (false) {
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY | \Attribute::TARGET_CLASS)]
class Groups
class Groups extends \Symfony\Component\Serializer\Attribute\Groups
{
}
}
2 changes: 1 addition & 1 deletion src/Symfony/Component/Serializer/Annotation/Ignore.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class_exists(\Symfony\Component\Serializer\Attribute\Ignore::class);

if (false) {
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY)]
final class Ignore
class Ignore extends \Symfony\Component\Serializer\Attribute\Ignore
{
}
}
2 changes: 1 addition & 1 deletion src/Symfony/Component/Serializer/Annotation/MaxDepth.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class_exists(\Symfony\Component\Serializer\Attribute\MaxDepth::class);

if (false) {
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY)]
class MaxDepth
class MaxDepth extends \Symfony\Component\Serializer\Attribute\MaxDepth
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class_exists(\Symfony\Component\Serializer\Attribute\SerializedName::class);

if (false) {
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY)]
final class SerializedName
class SerializedName extends \Symfony\Component\Serializer\Attribute\SerializedName
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class_exists(\Symfony\Component\Serializer\Attribute\SerializedPath::class);

if (false) {
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY)]
final class SerializedPath
class SerializedPath extends \Symfony\Component\Serializer\Attribute\SerializedPath
{
}
}
2 changes: 2 additions & 0 deletions src/Symfony/Component/Serializer/Attribute/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
* @Target({"PROPERTY", "METHOD"})
*
* @author Maxime Steinhausser <maxime.steinhausser@gmail.com>
*
* @final since Symfony 6.4
*/
#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::TARGET_PROPERTY | \Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
class Context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
* @Target({"CLASS"})
*
* @author Samuel Roze <samuel.roze@gmail.com>
*
* @final since Symfony 6.4
*/
#[\Attribute(\Attribute::TARGET_CLASS)]
class DiscriminatorMap
Expand Down
2 changes: 2 additions & 0 deletions src/Symfony/Component/Serializer/Attribute/Groups.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
* @Target({"PROPERTY", "METHOD", "CLASS"})
*
* @author Kévin Dunglas <dunglas@gmail.com>
*
* @final since Symfony 6.4
*/
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY | \Attribute::TARGET_CLASS)]
class Groups
Expand Down
4 changes: 3 additions & 1 deletion src/Symfony/Component/Serializer/Attribute/Ignore.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
* @Target({"PROPERTY", "METHOD"})
*
* @author Kévin Dunglas <dunglas@gmail.com>
*
* @final since Symfony 6.4
*/
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY)]
final class Ignore
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the @final annotation so that we don't support BC for child classes (as they might not work when reading attributes anyway)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough, should be noted that many other attributes (ie. in DependencyInjection) are also not marked final. Out of scope for this PR to look into that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some of them, it is intended as we explicit added support for extending them.

class Ignore
{
}

Expand Down
2 changes: 2 additions & 0 deletions src/Symfony/Component/Serializer/Attribute/MaxDepth.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
* @Target({"PROPERTY", "METHOD"})
*
* @author Kévin Dunglas <dunglas@gmail.com>
*
* @final since Symfony 6.4
*/
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY)]
class MaxDepth
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@
* @Target({"PROPERTY", "METHOD"})
*
* @author Fabien Bourigault <bourigaultfabien@gmail.com>
*
* @final since Symfony 6.4
*/
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY)]
final class SerializedName
class SerializedName
{
public function __construct(private readonly string $serializedName)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@
* @Target({"PROPERTY", "METHOD"})
*
* @author Tobias Bönner <tobi@boenner.family>
*
* @final since Symfony 6.4
*/
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY)]
final class SerializedPath
class SerializedPath
{
private PropertyPath $serializedPath;

Expand Down