From a5f6d240ecb447965ebb60c4cf3d506f5d8ad264 Mon Sep 17 00:00:00 2001 From: Guilhem Niot Date: Sat, 11 Mar 2017 20:58:57 +0100 Subject: [PATCH 1/4] [BC] Allow more changes when the class/method is final --- contributing/code/bc.rst | 52 +++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/contributing/code/bc.rst b/contributing/code/bc.rst index d2cf618ef70..a8249292ed3 100644 --- a/contributing/code/bc.rst +++ b/contributing/code/bc.rst @@ -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]_ @@ -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 @@ -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 @@ -212,30 +212,30 @@ Remove public method No 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 without a default value No [7]_ +Add argument with a default value No [7]_ 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]_ +Remove default value of an argument No [7]_ +Add type hint to an argument No [7]_ +Remove type hint of an argument No [7]_ +Change argument type No [7]_ +Change return type No [7]_ **Protected Methods** Add protected method Yes -Remove protected method No -Change name No -Reduce visibility No +Remove protected method No [7]_ +Change name No [7]_ +Reduce visibility No [7]_ 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]_ +Add argument with a default value No [7]_ 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]_ +Remove default value of an argument No [7]_ +Add type hint to an argument No [7]_ +Remove type hint of an argument No [7]_ +Change argument type No [7]_ +Change return type No [7]_ **Private Methods** Add private method Yes Remove private method Yes @@ -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]_ Turn static into non static No **Constants** Add constant Yes @@ -277,6 +277,10 @@ 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/method is final. + .. _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 From 4a3fbede228af9e5a4f2e6fed90e327b98ec7c66 Mon Sep 17 00:00:00 2001 From: Guilhem Niot Date: Mon, 13 Mar 2017 18:01:31 +0100 Subject: [PATCH 2/4] Fix comments --- contributing/code/bc.rst | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/contributing/code/bc.rst b/contributing/code/bc.rst index a8249292ed3..51538e36c66 100644 --- a/contributing/code/bc.rst +++ b/contributing/code/bc.rst @@ -212,15 +212,15 @@ Remove public method No Change name No Reduce visibility No Move to parent class Yes -Add argument without a default value No [7]_ -Add argument with a default value No [7]_ +Add argument without a default value No +Add argument with a default value No [7]_ [8]_ Remove argument Yes [3]_ -Add default value to an argument No [7]_ -Remove default value of an argument No [7]_ -Add type hint to an argument No [7]_ -Remove type hint of an argument No [7]_ -Change argument type No [7]_ -Change return type No [7]_ +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 [7]_ [8]_ +Change argument type No +Change return type No **Protected Methods** Add protected method Yes Remove protected method No [7]_ @@ -228,12 +228,12 @@ Change name No [7]_ Reduce visibility No [7]_ Move to parent class Yes Add argument without a default value No [7]_ -Add argument with a default value No [7]_ +Add argument with a default value No [7]_ [8]_ Remove argument Yes [3]_ -Add default value to an argument No [7]_ +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]_ -Remove type hint of an argument No [7]_ +Remove type hint of an argument No [7]_ [8]_ Change argument type No [7]_ Change return type No [7]_ **Private Methods** @@ -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 [7]_ +Turn non static into static No [7]_ [8]_ Turn static into non static No **Constants** Add constant Yes @@ -279,7 +279,9 @@ Change value of a constant Yes [1]_ [5]_ .. [6] Allowed using the ``@final`` annotation. -.. [7] Allowed if the class/method is final. +.. [7] Allowed if the class is final. + +.. [8] Allowed if the method is final. .. _Semantic Versioning: http://semver.org/ .. _scalar type: http://php.net/manual/en/function.is-scalar.php From 936200ceb70befb3865ff11665c917be1032b9e1 Mon Sep 17 00:00:00 2001 From: Guilhem Niot Date: Tue, 14 Mar 2017 20:38:19 +0100 Subject: [PATCH 3/4] Update --- contributing/code/bc.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/contributing/code/bc.rst b/contributing/code/bc.rst index 51538e36c66..3582a939893 100644 --- a/contributing/code/bc.rst +++ b/contributing/code/bc.rst @@ -217,10 +217,10 @@ Add argument with a default value No [7]_ [8]_ Remove argument Yes [3]_ Add default value to an argument No [7]_ [8]_ Remove default value of an argument No -Add type hint to 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 -Change return type No +Change argument type No [7]_ [8]_ +Change return type No [7]_ [8]_ **Protected Methods** Add protected method Yes Remove protected method No [7]_ @@ -232,10 +232,10 @@ Add argument with a default value No [7]_ [8]_ Remove argument Yes [3]_ 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]_ +Add type hint to an argument No [7]_ [8]_ Remove type hint of an argument No [7]_ [8]_ -Change argument type No [7]_ -Change return type No [7]_ +Change argument type No [7]_ [8]_ +Change return type No [7]_ [8]_ **Private Methods** Add private method Yes Remove private method Yes From f5b8dd452dcdabc9030618d1830fdab24b6ed69c Mon Sep 17 00:00:00 2001 From: Guilhem Niot Date: Wed, 15 Mar 2017 13:15:53 +0100 Subject: [PATCH 4/4] Improve notes --- contributing/code/bc.rst | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/contributing/code/bc.rst b/contributing/code/bc.rst index 3582a939893..f1e5d334fb9 100644 --- a/contributing/code/bc.rst +++ b/contributing/code/bc.rst @@ -279,9 +279,17 @@ Change value of a constant Yes [1]_ [5]_ .. [6] Allowed using the ``@final`` annotation. -.. [7] Allowed if the class is final. - -.. [8] Allowed if the method is final. +.. [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