@@ -50,7 +50,7 @@ sticks to these rules.
50
50
.. caution ::
51
51
52
52
The exception to this rule are interfaces tagged with ``@internal ``. Such
53
- interfaces should * never * be used or implemented.
53
+ interfaces should not be used or implemented.
54
54
55
55
If you want to implement an interface, you should first make sure that the
56
56
interface is an API interface. You can recognize API interfaces by the ``@api ``
@@ -69,9 +69,15 @@ tag in their source code::
69
69
}
70
70
71
71
If you implement an API interface, we promise that we won't ever break your
72
- code. Regular interfaces, by contrast, should never be implemented, because if
73
- we add a new method to the interface or add a new optional parameter to the
74
- signature of a method, we would generate a fatal error in your application.
72
+ code. Regular interfaces, by contrast, may be extended between minor releases,
73
+ for example by adding a new method. Be prepared to upgrade your code manually
74
+ if you implement a regular interface.
75
+
76
+ .. note ::
77
+
78
+ Even if we do changes that require manual upgrades, we limit ourselves to
79
+ changes that can be upgraded easily. We will always document the precise
80
+ upgrade instructions in the UPGRADE file in Symfony's root directory.
75
81
76
82
The following table explains in detail which use cases are covered by our
77
83
backwards compatibility promise:
@@ -89,9 +95,9 @@ backwards compatibility promise:
89
95
+-----------------------------------------------+---------------+---------------+
90
96
| Implement a method | No [1 ]_ | Yes |
91
97
+-----------------------------------------------+---------------+---------------+
92
- | Add a parameter to an implemented method | No [1 ]_ | Yes |
98
+ | Add an argument to an implemented method | No [1 ]_ | Yes |
93
99
+-----------------------------------------------+---------------+---------------+
94
- | Add a default value to a parameter | Yes | Yes |
100
+ | Add a default value to an argument | Yes | Yes |
95
101
+-----------------------------------------------+---------------+---------------+
96
102
97
103
.. include :: _api_tagging.rst.inc
@@ -107,7 +113,7 @@ public methods and properties.
107
113
Classes, properties and methods that bear the tag ``@internal `` as well as
108
114
the classes located in the various ``*\\Tests\\ `` namespaces are an
109
115
exception to this rule. They are meant for internal use only and should
110
- * never * be accessed by your own code.
116
+ not be accessed by your own code.
111
117
112
118
Just like with interfaces, we also distinguish between regular and API classes.
113
119
Like API interfaces, API classes are marked with an ``@api `` tag::
@@ -127,9 +133,15 @@ Like API interfaces, API classes are marked with an ``@api`` tag::
127
133
The difference between regular and API classes is that we guarantee full
128
134
backwards compatibility if you extend an API class and override its methods. We
129
135
can't give the same promise for regular classes, because there we may, for
130
- example, add an optional parameter to a method. Consequently, the signature of
136
+ example, add an optional argument to a method. Consequently, the signature of
131
137
your overridden method wouldn't match anymore and generate a fatal error.
132
138
139
+ .. note ::
140
+
141
+ As with interfaces, we limit ourselves to changes that can be upgraded
142
+ easily. We will document the precise ugprade instructions in the UPGRADE
143
+ file in Symfony's root directory.
144
+
133
145
In some cases, only specific properties and methods are tagged with the ``@api ``
134
146
tag, even though their class is not. In these cases, we guarantee full backwards
135
147
compatibility for the tagged properties and methods (as indicated in the column
@@ -171,9 +183,13 @@ covered by our backwards compatibility promise:
171
183
+-----------------------------------------------+---------------+---------------+
172
184
| Add a new method | No | No |
173
185
+-----------------------------------------------+---------------+---------------+
174
- | Add a parameter to an overridden method | No [1 ]_ | Yes |
186
+ | Add an argument to an overridden method | No [1 ]_ | Yes |
187
+ +-----------------------------------------------+---------------+---------------+
188
+ | Add a default value to an argument | Yes | Yes |
189
+ +-----------------------------------------------+---------------+---------------+
190
+ | Call a private method (via Reflection) | No | No |
175
191
+-----------------------------------------------+---------------+---------------+
176
- | Add a default value to a parameter | Yes | Yes |
192
+ | Access a private property (via Reflection) | No | No |
177
193
+-----------------------------------------------+---------------+---------------+
178
194
179
195
.. include :: _api_tagging.rst.inc
@@ -201,14 +217,14 @@ Remove parent interface No No
201
217
Add method Yes [2 ]_ No
202
218
Remove method No No
203
219
Change name No No
204
- Add parameter without a default value No No
205
- Add parameter with a default value Yes [2 ]_ No
206
- Remove parameter Yes [3 ]_ Yes [3 ]_
207
- Add default value to a parameter Yes [2 ]_ No
208
- Remove default value of a parameter No No
209
- Add type hint to a parameter No No
210
- Remove type hint of a parameter Yes [2 ]_ No
211
- Change parameter type Yes [2 ]_ [4 ]_ No
220
+ Add argument without a default value No No
221
+ Add argument with a default value Yes [2 ]_ No
222
+ Remove argument Yes [3 ]_ Yes [3 ]_
223
+ Add default value to an argument Yes [2 ]_ No
224
+ Remove default value of an argument No No
225
+ Add type hint to an argument No No
226
+ Remove type hint of an argument Yes [2 ]_ No
227
+ Change argument type Yes [2 ]_ [4 ]_ No
212
228
Change return type Yes [2 ]_ [5 ]_ No
213
229
============================================== ============== ==============
214
230
@@ -236,8 +252,11 @@ Reduce visibility No No
236
252
Add protected property Yes Yes
237
253
Remove protected property Yes [2 ]_ No
238
254
Reduce visibility Yes [2 ]_ No
255
+ **Private Properties **
256
+ Add private property Yes Yes
257
+ Remove private property Yes Yes
239
258
**Constructors **
240
- Add constructor without mandatory parameters Yes [2 ]_ Yes [2 ]_
259
+ Add constructor without mandatory arguments Yes [2 ]_ Yes [2 ]_
241
260
Remove constructor Yes [2 ]_ No
242
261
Reduce visibility of a public constructor No No
243
262
Reduce visibility of a protected constructor Yes [2 ]_ No
@@ -246,29 +265,43 @@ Add public method Yes Yes
246
265
Remove public method No No
247
266
Change name No No
248
267
Reduce visibility No No
249
- Add parameter without a default value No No
250
- Add parameter with a default value Yes [2 ]_ No
251
- Remove parameter Yes [3 ]_ Yes [3 ]_
252
- Add default value to a parameter Yes [2 ]_ No
253
- Remove default value of a parameter No No
254
- Add type hint to a parameter Yes [7 ]_ No
255
- Remove type hint of a parameter Yes [2 ]_ No
256
- Change parameter type Yes [2 ]_ [4 ]_ No
268
+ Add argument without a default value No No
269
+ Add argument with a default value Yes [2 ]_ No
270
+ Remove argument Yes [3 ]_ Yes [3 ]_
271
+ Add default value to an argument Yes [2 ]_ No
272
+ Remove default value of an argument No No
273
+ Add type hint to an argument Yes [7 ]_ No
274
+ Remove type hint of an argument Yes [2 ]_ No
275
+ Change argument type Yes [2 ]_ [4 ]_ No
257
276
Change return type Yes [2 ]_ [5 ]_ No
258
277
**Protected Methods **
259
278
Add protected method Yes Yes
260
279
Remove protected method Yes [2 ]_ No
261
280
Change name No No
262
281
Reduce visibility Yes [2 ]_ No
263
- Add parameter without a default value Yes [2 ]_ No
264
- Add parameter with a default value Yes [2 ]_ No
265
- Remove parameter Yes [3 ]_ Yes [3 ]_
266
- Add default value to a parameter Yes [2 ]_ No
267
- Remove default value of a parameter Yes [2 ]_ No
268
- Add type hint to a parameter Yes [2 ]_ No
269
- Remove type hint of a parameter Yes [2 ]_ No
270
- Change parameter type Yes [2 ]_ [4 ]_ No
282
+ Add argument without a default value Yes [2 ]_ No
283
+ Add argument with a default value Yes [2 ]_ No
284
+ Remove argument Yes [3 ]_ Yes [3 ]_
285
+ Add default value to an argument Yes [2 ]_ No
286
+ Remove default value of an argument Yes [2 ]_ No
287
+ Add type hint to an argument Yes [2 ]_ No
288
+ Remove type hint of an argument Yes [2 ]_ No
289
+ Change argument type Yes [2 ]_ [4 ]_ No
271
290
Change return type Yes [2 ]_ [5 ]_ No
291
+ **Private Methods **
292
+ Add private method Yes Yes
293
+ Remove private method Yes Yes
294
+ Change name Yes Yes
295
+ Reduce visibility Yes Yes
296
+ Add argument without a default value Yes Yes
297
+ Add argument with a default value Yes Yes
298
+ Remove argument Yes Yes
299
+ Add default value to an argument Yes Yes
300
+ Remove default value of an argument Yes Yes
301
+ Add type hint to an argument Yes Yes
302
+ Remove type hint of an argument Yes Yes
303
+ Change argument type Yes Yes
304
+ Change return type Yes Yes
272
305
================================================== ============== ==============
273
306
274
307
.. [1 ] Your code may be broken by changes in the Symfony code. Such changes will
@@ -277,9 +310,10 @@ Change return type Yes [2]_ [5]_ No
277
310
.. [2 ] Should be avoided. When done, this change must be documented in the
278
311
UPGRADE file.
279
312
280
- .. [3 ] Only the last parameter(s) of a method may be removed.
313
+ .. [3 ] Only the last argument(s) of a method may be removed, as PHP does not
314
+ care about additional arguments that you pass to a method.
281
315
282
- .. [4 ] The parameter type may only be changed to a compatible or less specific
316
+ .. [4 ] The argument type may only be changed to a compatible or less specific
283
317
type. The following type changes are allowed:
284
318
285
319
=================== ==================================================================
0 commit comments