|
| 1 | +Our Backwards Compatibility Promise |
| 2 | +=================================== |
| 3 | + |
| 4 | +As of Symfony 2.1, we promise you backwards compatibility for all further 2.x |
| 5 | +releases. Ensuring smooth upgrades of your projects is our first priority. |
| 6 | +However, backwards compatibility comes in many different flavors. This page |
| 7 | +lists which code changes are covered by our promise and to what degree. |
| 8 | + |
| 9 | +If you are contributing to Symfony, make sure that your code changes comply to |
| 10 | +the rules listed below. |
| 11 | + |
| 12 | +.. note:: |
| 13 | + |
| 14 | + This promise is in trial until April 15th, 2014. Until then, we may change |
| 15 | + parts of it if we discover problems or limitations. |
| 16 | + |
| 17 | + |
| 18 | +Interfaces |
| 19 | +---------- |
| 20 | + |
| 21 | +Normal Interfaces |
| 22 | +~~~~~~~~~~~~~~~~~ |
| 23 | + |
| 24 | +All interfaces in the ``Symfony`` namespace are **safe for use**. That means |
| 25 | +that: |
| 26 | + |
| 27 | +* You can safely type hint against the interface. |
| 28 | + |
| 29 | +* You can safely use any of the methods provided by the interface. |
| 30 | + |
| 31 | +However: |
| 32 | + |
| 33 | +* You cannot safely implement the interface. The interface may change, but all |
| 34 | + changes will be documented in the UPGRADE file. |
| 35 | + |
| 36 | +Methods tagged with ``@api`` are treated as if they belonged to an API |
| 37 | +interface. |
| 38 | + |
| 39 | + |
| 40 | +API Interfaces |
| 41 | +~~~~~~~~~~~~~~ |
| 42 | + |
| 43 | +All interfaces tagged with ``@api`` are also **safe for implementation**. That |
| 44 | +means that: |
| 45 | + |
| 46 | +* You can safely implement the interface. |
| 47 | + |
| 48 | + |
| 49 | +Allowed Changes |
| 50 | +~~~~~~~~~~~~~~~ |
| 51 | + |
| 52 | +============================================== ============== ============== |
| 53 | +Type of Change Normal API |
| 54 | +============================================== ============== ============== |
| 55 | +Remove entirely No No |
| 56 | +Change name or namespace No No |
| 57 | +Add parent interface Yes [1]_ No |
| 58 | +Remove parent interface No No |
| 59 | +**Methods** |
| 60 | +Add method Yes [1]_ No |
| 61 | +Remove method No No |
| 62 | +Change name No No |
| 63 | +Add parameter without a default value No No |
| 64 | +Add parameter with a default value Yes [1]_ No |
| 65 | +Remove parameter No No |
| 66 | +Add default value to a parameter Yes [1]_ No |
| 67 | +Remove default value of a parameter No No |
| 68 | +Add type hint to a parameter No No |
| 69 | +Remove type hint of a parameter Yes [1]_ No |
| 70 | +Change return type Yes [1]_ [2]_ No |
| 71 | +============================================== ============== ============== |
| 72 | + |
| 73 | + |
| 74 | +Classes |
| 75 | +------- |
| 76 | + |
| 77 | +Normal Classes |
| 78 | +~~~~~~~~~~~~~~ |
| 79 | + |
| 80 | +All classes in the ``Symfony`` namespace are **safe for use**. That means that: |
| 81 | + |
| 82 | +* You can safely create new instances. |
| 83 | + |
| 84 | +* You can safely extend the class. |
| 85 | + |
| 86 | +* You can safely use public properties and methods. |
| 87 | + |
| 88 | +When extending the class: |
| 89 | + |
| 90 | +* You can safely override public properties. |
| 91 | + |
| 92 | +* You cannot safely use protected properties and methods. We may change or |
| 93 | + remove them, but will document this in the UPGRADE file. |
| 94 | + |
| 95 | +* You cannot safely override protected properties. We may change or |
| 96 | + remove them, but will document this in the UPGRADE file. |
| 97 | + |
| 98 | +* You cannot safely override public or protected methods. We may change them, |
| 99 | + but will document this in the UPGRADE file. |
| 100 | + |
| 101 | +* You cannot safely add public or protected properties. We may add a property |
| 102 | + with the same name. |
| 103 | + |
| 104 | +* You cannot safely add a new public or protected method. We may add a method |
| 105 | + with the same name. |
| 106 | + |
| 107 | +* You cannot safely add parameters to overridden methods. We may do the same. |
| 108 | + |
| 109 | +Properties and methods tagged with ``@api`` are treated as if they belonged |
| 110 | +to an API class. |
| 111 | + |
| 112 | + |
| 113 | +API Classes |
| 114 | +~~~~~~~~~~~ |
| 115 | + |
| 116 | +All classes tagged with ``@api`` are also **safe for extension**. That means |
| 117 | +that: |
| 118 | + |
| 119 | +* You can safely use protected properties and methods. |
| 120 | + |
| 121 | +* You can safely override protected properties. |
| 122 | + |
| 123 | +* You can safely override public or protected methods. |
| 124 | + |
| 125 | + |
| 126 | +Allowed Changes |
| 127 | +~~~~~~~~~~~~~~~ |
| 128 | + |
| 129 | +================================================== ============== ============== |
| 130 | +Type of Change Normal API |
| 131 | +================================================== ============== ============== |
| 132 | +Remove entirely No No |
| 133 | +Make final Yes [1]_ No |
| 134 | +Make abstract No No |
| 135 | +Change name or namespace No No |
| 136 | +Change parent class Yes [3]_ Yes [3]_ |
| 137 | +Add interface Yes Yes |
| 138 | +Remove interface No No |
| 139 | +**Public Properties** |
| 140 | +Add public property Yes Yes |
| 141 | +Remove public property No No |
| 142 | +Reduce visibility No No |
| 143 | +**Protected Properties** |
| 144 | +Add protected property Yes Yes |
| 145 | +Remove protected property Yes [1]_ No |
| 146 | +Reduce visibility Yes [1]_ No |
| 147 | +**Constructors** |
| 148 | +Add constructor without mandatory parameters Yes [1]_ Yes [1]_ |
| 149 | +Remove constructor Yes [1]_ No |
| 150 | +Reduce visibility of a public constructor No No |
| 151 | +Reduce visibility of a protected constructor Yes [1]_ No |
| 152 | +**Public Methods** |
| 153 | +Add public method Yes Yes |
| 154 | +Remove public method No No |
| 155 | +Change name No No |
| 156 | +Reduce visibility No No |
| 157 | +Add parameter without a default value No No |
| 158 | +Add parameter with a default value Yes Yes |
| 159 | +Remove parameter No No |
| 160 | +Add default value to a parameter Yes [1]_ No |
| 161 | +Remove default value of a parameter No No |
| 162 | +Add type hint to a parameter Yes [4]_ No |
| 163 | +Remove type hint of a parameter Yes [1]_ No |
| 164 | +Change return type Yes [1]_ [2]_ No |
| 165 | +**Protected Methods** |
| 166 | +Add protected method Yes Yes |
| 167 | +Remove protected method Yes [1]_ No |
| 168 | +Change name No No |
| 169 | +Reduce visibility Yes [1]_ No |
| 170 | +Add parameter without a default value Yes [1]_ No |
| 171 | +Add parameter with a default value Yes Yes |
| 172 | +Remove parameter Yes [1]_ No |
| 173 | +Add default value to a parameter Yes [1]_ No |
| 174 | +Remove default value of a parameter Yes [1]_ No |
| 175 | +Add type hint to a parameter Yes [1]_ No |
| 176 | +Remove type hint of a parameter Yes [1]_ No |
| 177 | +Change return type Yes [1]_ [2]_ No |
| 178 | +================================================== ============== ============== |
| 179 | + |
| 180 | + |
| 181 | +.. [1] Should be avoided. When done, this change must be documented in the |
| 182 | + UGPRADE file. |
| 183 | +
|
| 184 | +.. [2] The return type may only be changed to compatible types. **TODO define |
| 185 | + type compatibility** |
| 186 | +
|
| 187 | +.. [3] When changing the parent class, the original parent class must remain an |
| 188 | + ancestor of the class. |
| 189 | +
|
| 190 | +.. [4] A type hint may only be added if passing a value with a different type |
| 191 | + previously generated a fatal error. |
0 commit comments