Skip to content

Add BC promise rules for constructors #20307

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
Oct 16, 2024
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 @@ -258,6 +258,14 @@ Make public or protected Yes
Remove private property Yes
**Constructors**
Add constructor without mandatory arguments Yes :ref:`[1] <note-1>`
:ref:`Add argument without a default value <add-argument-public-method>` No
Add argument with a default value Yes :ref:`[11] <note-11>`
Remove argument No :ref:`[3] <note-3>`
Add default value to an argument Yes
Remove default value of an argument No
Add type hint to an argument No
Copy link
Member

Choose a reason for hiding this comment

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

we should probably update the whole table (maybe in a separate PR) to stop talking about type hint. Those are not hints at all. the right term for that is type, or maybe native type if we want to compare it to phpdoc-declared types.

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree, I'll have a loot at it once this one is merged

Remove type hint of an argument Yes
Change argument type No
Remove constructor No
Reduce visibility of a public constructor No
Reduce visibility of a protected constructor No :ref:`[7] <note-7>`
Expand Down Expand Up @@ -473,6 +481,10 @@ a return type is only possible with a child type.
constructors of Attribute classes. Using PHP named arguments might break your
code when upgrading to newer Symfony versions.

.. _note-11:

**[11]** Only optional argument(s) of a constructor at last position may be added.

Making Code Changes in a Backward Compatible Way
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
Loading