E531 Documentation around `@final since` by greg0ire · Pull Request #21708 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content

Documentation around @final since#21708

Open
greg0ire wants to merge 2 commits intosymfony:6.4from
greg0ire:final-since
Open

Documentation around @final since#21708
greg0ire wants to merge 2 commits intosymfony:6.4from
greg0ire:final-since

Conversation

@greg0ire
Copy link
Copy Markdown
Contributor
@greg0ire greg0ire commented Jan 10, 2026

We (the Doctrine team) have started using @final since in Doctrine, and would like some documentation about it.

The "since x.y" makes it easier to figure out whether something should
be considered final or not.
@carsonbot carsonbot added this to the 6.4 milestone Jan 10, 2026
@carsonbot carsonbot changed the title Documentation around @final since Documentation around @final since Jan 10, 2026
.. _note-6:

**[6]** Allowed using the ``@final`` annotation.
**[6]** Allowed using the ``@final since x.y`` annotation.
Copy link
Copy Markdown
Contributor Author
@greg0ire greg0ire Jan 10, 2026

Choose a reason for hiding this comment

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

Looking at the codebase, I see that Symfony actually uses @final since Symfony x.y or @final since version x.y, but maybe this is a good time to challenge this practice and make it more universal? Or is there a purpose to mentioning Symfony here? I do not know how Symfony tooling uses @final since. Apparently there is that will cause a deprecation upon seeing @final, but I don't think it does anything with the text that follows.

https://github.com/symfony/symfony/blob/9d1aaf407973a6a2a002ea359d89f8ae18afce0e/src/Symfony/Component/ErrorHandler/DebugClassLoader.php#L425-L427

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The DebugErrorHandler will include the tag description in the deprecation message (for any @final tag.
Sayig @final since Symfony 8.1 will then read The class ... is considered final since Symfony 8.1.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

OK. I've added Symfony everywhere and illustrated what you're saying with since last friday to make it clear that this is printed verbatim.

Comment on lines +569 to +570
That is also considered a breaking change, as it reduces the list of
things that are a breaking change.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

How is adding a phpDoc annotation a breaking change?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If adding that annotation means it's suddenly OK to do other breaking changes, such as removing a protected property, then it is a breaking change, isn't it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Although, I get what you're saying, there is no way this is going to break code on its own… but I guess it breaks a promise, the promise not to alter the contract… it's a bit meta.

Copy link
Copy Markdown
@morozov morozov Jan 11, 2026

Choose a reason for hiding this comment

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

I see. What you're saying makes sense, but the wording may be misleading. Adding @final itself is not a breaking change as it doesn't violate any contract, but it may lead to making actual breaking changes accidentally.

Copy link
Copy Markdown
Contributor Author FF8

Choose a reason for hiding this comment

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

Yes. I will try to reword this 🤔

@OskarStark OskarStark changed the title Documentation around @final since Documentation around @final since Jan 12, 2026
Comment on lines +574 to +575
For that reason, the addition of an ``@final`` annotation should never
happen in a minor or patch release, at least not in this short form.
Copy link
Copy Markdown
@morozov morozov Jan 12, 2026

Choose a reason for hiding this comment

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

The "at least not in this short form" wording implies that adding @final since in a minor or patch release is sorta okay. However, it's perfectly fine to add @final since in a minor release and is not fine at all in a patch.

It may create confusion, so I'd drop this part.

Comment on lines +574 to +575
For that reason, the addition of an ``@final`` annotation should never
happen in a minor release.
Copy link
Copy Markdown
@morozov morozov Jan 13, 2026

Choose a reason for hiding this comment

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

By the time when a reader has reached this sentence, they haven't read about @final since yet. So this sentence may read as "you cannot add any @final annotation in a minor release", but this is not what this sentence attempts to say.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

0