Skip to content

Update BC policy to tell about adding/removing return types #9717

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
May 15, 2018
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
Diff view
12 changes: 12 additions & 0 deletions contributing/code/bc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ backward compatibility promise:
+-----------------------------------------------+-----------------------------+
| Add a default value to an argument | Yes |
+-----------------------------------------------+-----------------------------+
| Add a return type to an implemented method | Yes |
+-----------------------------------------------+-----------------------------+

Using our Classes
~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -164,6 +166,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
Add return type No
Remove return type No [9]_
Change return type No
**Constants**
Add constant Yes
Expand Down Expand Up @@ -220,6 +224,8 @@ Remove default value of an argument 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]_
Add return type No [7]_ [8]_
Remove return type No [7]_ [8]_ [9]_
Change return type No [7]_ [8]_
**Protected Methods**
Add protected method Yes
Expand All @@ -235,6 +241,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]_
Add return type No [7]_ [8]_
Remove return type No [7]_ [8]_ [9]_
Change return type No [7]_ [8]_
**Private Methods**
Add private method Yes
Expand All @@ -248,6 +256,8 @@ Remove default value of an argument Yes
Add type hint to an argument Yes
Remove type hint of an argument Yes
Change argument type Yes
Add return type Yes
Remove return type Yes
Change return type Yes
**Static Methods**
Turn non static into static No [7]_ [8]_
Expand Down Expand Up @@ -291,6 +301,8 @@ Change value of a constant Yes [1]_ [5]_
Changing an argument type is only possible with a parent type.
Changing a return type is only possible with a child type.

.. [9] Allowed for the ``void`` return type.
Copy link
Member

Choose a reason for hiding this comment

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

Are you saying that void is an exception then? That, for example, adding/removing a return type would be a BC break... except for void?

Copy link
Member Author

@nicolas-grekas nicolas-grekas May 2, 2018

Choose a reason for hiding this comment

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

Yes, that's what I mean. Technically, PHP allows removing the return type without breaking children. But doing so would allow breaking contracts. Except for void.


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