8000 [BC] Allow more changes when the class/method is final by GuilhemN · Pull Request #7611 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content

[BC] Allow more changes when the class/method is final #7611

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 4 commits into from
Oct 29, 2017
Merged
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
10000
Diff view
58 changes: 36 additions & 22 deletions contributing/code/bc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ Symfony's classes:
Type of Change Change Allowed
================================================== ==============
Remove entirely No
Make final No
Make final No [6]_
Make abstract No
Change name or namespace No
Change parent class Yes [4]_
Expand All @@ -194,8 +194,8 @@ Reduce visibility No
Move to parent class Yes
**Protected Properties**
Add protected property Yes
Remove protected property No
Reduce visibility No
Remove protected property No [7]_
Reduce visibility No [7]_
Move to parent class Yes
**Private Properties**
Add private property Yes
Expand All @@ -204,7 +204,7 @@ Remove private property Yes
Add constructor without mandatory arguments Yes [1]_
Remove constructor No
Reduce visibility of a public constructor No
Reduce visibility of a protected constructor No
Reduce visibility of a protected constructor No [7]_
Move to parent class Yes
**Public Methods**
Add public method Yes
Expand All @@ -213,29 +213,29 @@ Change name No
Reduce visibility No
Move to parent class Yes
Add argument without a default value No
Add argument with a default value No
Add argument with a default value No [7]_ [8]_
Remove argument Yes [3]_
Add default value to an argument No
Add default value to an argument No [7]_ [8]_
Remove default value of an argument No
Add type hint to an argument No
Remove type hint of an argument No
Change argument type No
Change return type No
Add type hint to an argument No [7]_ [8]_
Remove type hint of an argument No [7]_ [8]_
Change argument type No [7]_ [8]_
Change return type No [7]_ [8]_
**Protected Methods**
Add protected method 10000 Yes
Remove protected method No
Change name No
Reduce visibility No
Remove protected method No [7]_
Change name No [7]_
Reduce visibility No [7]_
Copy link
Member
@xabbuh xabbuh Mar 13, 2017

Choose a reason for hiding this comment

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

[8] applies to all three above too, doesn't it? nope

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No because having a final protected method doesn't prevent people extending the class from calling the method.

Move to parent class Yes
Add argument without a default value No
Add argument with a default value No
Add argument without a default value No [7]_
Copy link
Member

Choose a reason for hiding this comment

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

this looks wrong to me

Copy link
Contributor Author
@GuilhemN GuilhemN Mar 13, 2017

Choose a reason for hiding this comment

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

I updated the notes to separate final classes and final methods.
A protected method in a final class is like a private method so this change is allowed, but it is not for a final method, so it should be ok now.

Thanks for your comments!

Add argument with a default value No [7]_ [8]_
Remove argument Yes [3]_
Add default value to an argument No
Remove default value of an argument No
Add type hint to an argument No
Remove type hint of an argument No
Change argument type No
Change return type No
Add default value to an argument No [7]_ [8]_
Remove default value of an argument No [7]_
Add type hint to an argument No [7]_ [8]_
Remove type hint of an argument No [7]_ [8]_
Change argument type No [7]_ [8]_
Change return type No [7]_ [8]_
**Private Methods**
Add private method Yes
Remove private method Yes
Expand All @@ -250,7 +250,7 @@ Remove type hint of an argument Yes
Change argument type Yes
Change return type Yes
**Static Methods**
Turn non static into static No
Turn non static into static No [7]_ [8]_
Turn static into non static No
**Constants**
Add constant Yes
Expand All @@ -277,6 +277,20 @@ Change value of a constant Yes [1]_ [5]_
Additionally, if a constant will likely be used in objects that are
serialized, the value of a constant should not be changed.

.. [6] Allowed using the ``@final`` annotation.

.. [7] Allowed if the class is final. Classes that received the ``@final``
annotation after their first release are considered final in their
next major version.
Changing an argument type is only possible with a parent type.
Changing a return type is only possible with a child type.

.. [8] Allowed if the method is final. Methods that received the ``@final``
annotation after their first release are considered final in their
next major version.
Changing an argument type is only possible with a parent type.
Changing a return type is only possible with a child type.

.. _Semantic Versioning: http://semver.org/
.. _scalar type: http://php.net/manual/en/function.is-scalar.php
.. _boolean values: http://php.net/manual/en/function.boolval.php
Expand Down
0