1
1
Our Backwards Compatibility Promise
2
2
===================================
3
3
4
- As of Symfony 2.3, we promise you backwards compatibility (BC) for all further
5
- 2.x releases. Ensuring smooth upgrades of your projects is our first priority.
6
- However, backwards compatibility comes in many different flavors.
4
+ If you are using Symfony, we promise you backwards compatibility (BC) for all
5
+ major releases (2.x, 3.x, ...). Ensuring smooth upgrades of your projects is our
6
+ first priority. However, backwards compatibility comes in many different flavors.
7
+
8
+ .. note ::
9
+
10
+ This promise was introduced with Symfony 2.3 and does not apply to previous
11
+ versions of Symfony.
7
12
8
13
This page has two different target audiences: If you are using Symfony, it will
9
14
tell you how to make sure that you will be able to upgrade smoothly to all
10
15
future 2.x versions. If you are contributing to Symfony, this page will tell you
11
16
the rules that you need to follow to ensure smooth upgrades for our users.
12
17
13
- .. note ::
14
-
15
- This promise is in trial until April 15th, 2014. Until then, we may change
16
- parts of it if we discover problems or limitations.
17
-
18
-
19
18
Using Symfony Code
20
19
------------------
21
20
22
- You are using Symfony in your projects? Then stick to the guidelines in this
23
- section in order to guarantee smooth upgrades to all future 2.x versions.
24
-
21
+ If you are using Symfony in your projects, the following guidelines will help
22
+ you to ensure smooth upgrades to all future minor releases of Symfony (such as
23
+ 2.5, 2.6 and so on).
25
24
26
25
Using Our Interfaces
27
26
~~~~~~~~~~~~~~~~~~~~
28
27
29
- In Symfony, we distinguish between regular and API interfaces. API interfaces
30
- are marked with an ``@api `` tag in their source code. For example::
28
+ All interfaces shipped with Symfony can be used in type hints. You can also call
29
+ any of the methods that they declare. We guarantee that we won't break code that
30
+ sticks to these rules.
31
+
32
+ .. note ::
33
+
34
+ The exception to this rule are interfaces tagged with ``@internal ``. Such
35
+ interfaces should never be used or implemented.
36
+
37
+ If you want to implement an interface, you should first make sure that the
38
+ interface is an API interface. You can recognize API interfaces by the ``@api ``
39
+ tag in their source code::
31
40
32
41
/**
33
42
* HttpKernelInterface handles a Request to convert it to a Response.
@@ -39,40 +48,51 @@ are marked with an ``@api`` tag in their source code. For example::
39
48
interface HttpKernelInterface
40
49
{
41
50
42
- In simple words, the difference between regular and API interfaces is that you
43
- can implement API interfaces yourself and we will guarantee full backwards
44
- compatibility. The same is not true for regular interfaces: We may, for example,
45
- add an optional parameter or a new method to them and thus break your own
46
- implementation.
47
-
48
- In detail, we guarantee full backwards compatibility for the following use
49
- cases:
50
-
51
- ============================================== ============== ==============
52
- Use Case Regular API
53
- ============================================== ============== ==============
54
- Type hint against Yes Yes
55
- Call method Yes Yes
56
- **In Implementing Classes **
57
- Implement method No [1 ]_ Yes
58
- Add custom method No [1 ]_ Yes
59
- Add custom method parameter No [1 ]_ Yes
60
- Add parameter default value Yes Yes
61
- ============================================== ============== ==============
51
+ If you implement an API interface, we promise that we won't ever break your
52
+ code. Regular interfaces, by contrast, should never be implemented, because if
53
+ we add a new method to the interface or add a new optional parameter to the
54
+ signature of a method, we would generate a fatal error in your application.
55
+
56
+ The following table explains in detail which use cases are covered by our
57
+ backwards compatibility promise:
58
+
59
+ +-----------------------------------------------+---------------+---------------+
60
+ | Use Case | Regular | API |
61
+ +-----------------------------------------------+---------------+---------------+
62
+ | If you... | Then we guarantee BC... |
63
+ +===============================================+===============+===============+
64
+ | Type hint against the interface | Yes | Yes |
65
+ +-----------------------------------------------+---------------+---------------+
66
+ | Call a method | Yes | Yes |
67
+ +-----------------------------------------------+---------------+---------------+
68
+ | **If you implement the interface and... ** | **Then we guarantee BC... ** |
69
+ +-----------------------------------------------+---------------+---------------+
70
+ | Implement a method | No [1 ]_ | Yes |
71
+ +-----------------------------------------------+---------------+---------------+
72
+ | Add a parameter to an implemented method | No [1 ]_ | Yes |
73
+ +-----------------------------------------------+---------------+---------------+
74
+ | Add a default value to a parameter | Yes | Yes |
75
+ +-----------------------------------------------+---------------+---------------+
62
76
63
77
.. note ::
64
78
65
- If you need to do any of the things marked with "No" above, feel free to
66
- ask us whether the ``@api `` tag can be added on the respective Symfony code.
67
- For that, simply open a `new ticket on GitHub `_.
68
-
69
- Interfaces or interface methods tagged with ``@internal `` should never be
70
- implemented or used.
71
-
79
+ If you think that one of our regular interfaces should have an ``@api `` tag,
80
+ put your request into a `new ticket on GitHub `_. We will then evaluate
81
+ whether we can add the tag or not.
72
82
73
83
Using Our Classes
74
84
~~~~~~~~~~~~~~~~~
75
85
86
+ All classes provided by Symfony may be instantiated and accessed through their
87
+ public methods and properties.
88
+
89
+ .. note ::
90
+
91
+ Classes, properties and methods that bear the tag ``@internal `` as well as
92
+ the classes located in the various ``*\\Tests\\ `` namespaces are an
93
+ exception to this rule. They are meant for internal use only and should not
94
+ be accessed by your own code.
95
+
76
96
Just like with interfaces, we also distinguish between regular and API classes.
77
97
Like API interfaces, API classes are marked with an ``@api `` tag::
78
98
@@ -87,57 +107,69 @@ Like API interfaces, API classes are marked with an ``@api`` tag::
87
107
{
88
108
89
109
The difference between regular and API classes is that we guarantee full
90
- backwards compatibility if you extend an API class and override its methods,
91
- but not for regular classes. In regular classes, we may for example add an
92
- optional parameter to a method and thus break your overridden method.
93
-
94
- Again, here are the details about which use cases we guarantee full backwards
95
- compatibility for:
96
-
97
- ============================================== ============== ==============
98
- Use Case Regular API
99
- ============================================== ============== ==============
100
- Type hint against Yes Yes
101
- Create instance Yes Yes
102
- Extend Yes Yes
103
- Access public property Yes Yes
104
- Call public method Yes Yes
105
- **In Extending Classes **
106
- Access protected property No [1 ]_ Yes
107
- Call protected method No [1 ]_ Yes
108
- Override public property Yes Yes
109
- Override protected property No [1 ]_ Yes
110
- Override public method No [1 ]_ Yes
111
- Override protected method No [1 ]_ Yes
112
- Add custom property No No
113
- Add custom method No No
114
- Add custom method parameter No [1 ]_ Yes
115
- Add parameter default value Yes Yes
116
- ============================================== ============== ==============
117
-
118
- .. note ::
119
-
120
- If you need to do any of the things marked with "No" above, feel free to
121
- ask us whether the ``@api `` tag can be added on the respective Symfony code.
122
- For that, simply open a `new ticket on GitHub `_.
110
+ backwards compatibility if you extend an API class and override its methods. We
111
+ can't give the same promise for regular classes, because there we may, for
112
+ example, add an optional parameter to a method. Consequently, the signature of
113
+ your overridden method won't match anymore and generate a fatal error.
123
114
124
115
In some cases, only specific properties and methods are tagged with the ``@api ``
125
116
tag, even though their class is not. In these cases, we guarantee full backwards
126
117
compatibility for the tagged properties and methods (as indicated in the column
127
- "API" above), but not for the rest of the class.
118
+ "API" below), but not for the rest of the class.
119
+
120
+ To be on the safe side, check the following table to know which use cases are
121
+ covered by our backwards compatibility promise:
122
+
123
+ +-----------------------------------------------+---------------+---------------+
124
+ | Use Case | Regular | API |
125
+ +-----------------------------------------------+---------------+---------------+
126
+ | If you... | Then we guarantee BC... |
127
+ +===============================================+===============+===============+
128
+ | Type hint against the class | Yes | Yes |
129
+ +-----------------------------------------------+---------------+---------------+
130
+ | Create a new instance | Yes | Yes |
131
+ +-----------------------------------------------+---------------+---------------+
132
+ | Extend the class | Yes | Yes |
133
+ +-----------------------------------------------+---------------+---------------+
134
+ | Access a public property | Yes | Yes |
135
+ +-----------------------------------------------+---------------+---------------+
136
+ | Call a public method | Yes | Yes |
137
+ +-----------------------------------------------+---------------+---------------+
138
+ | **If you extend the class and... ** | **Then we guarantee BC... ** |
139
+ +-----------------------------------------------+---------------+---------------+
140
+ | Access a protected property | No [1 ]_ | Yes |
141
+ +-----------------------------------------------+---------------+---------------+
142
+ | Call a protected methods | No [1 ]_ | Yes |
143
+ +-----------------------------------------------+---------------+---------------+
144
+ | Override a public property | Yes | Yes |
145
+ +-----------------------------------------------+---------------+---------------+
146
+ | Override a protected property | No [1 ]_ | Yes |
147
+ +-----------------------------------------------+---------------+---------------+
148
+ | Override a public method | No [1 ]_ | Yes |
149
+ +-----------------------------------------------+---------------+---------------+
150
+ | Override a protected method | No [1 ]_ | Yes |
151
+ +-----------------------------------------------+---------------+---------------+
152
+ | Add a new property | No | No |
153
+ +-----------------------------------------------+---------------+---------------+
154
+ | Add a new method | No | No |
155
+ +-----------------------------------------------+---------------+---------------+
156
+ | Add a parameter to an overridden method | No [1 ]_ | Yes |
157
+ +-----------------------------------------------+---------------+---------------+
158
+ | Add a default value to a parameter | Yes | Yes |
159
+ +-----------------------------------------------+---------------+---------------+
128
160
129
- Classes, properties and methods tagged with ``@internal `` should never be
130
- created, extended or called directly. The same applies to all classes located in
131
- the various ``*\\Tests\\ `` namespaces.
161
+ .. note ::
132
162
163
+ If you think that one of our regular classes should have an ``@api `` tag,
164
+ put your request into a `new ticket on GitHub `_. We will then evaluate
165
+ whether we can add the tag or not.
133
166
134
167
Working on Symfony Code
135
168
-----------------------
136
169
137
170
Do you want to help us improve Symfony? That's great! However, please stick
138
171
to the rules listed below in order to ensure smooth upgrades for our users.
139
172
140
-
141
173
Changing Interfaces
142
174
~~~~~~~~~~~~~~~~~~~
143
175
@@ -166,7 +198,6 @@ Change parameter type Yes [2]_ [4]_ No
166
198
Change return type Yes [2 ]_ [5 ]_ No
167
199
============================================== ============== ==============
168
200
169
-
170
201
Changing Classes
171
202
~~~~~~~~~~~~~~~~
172
203
@@ -226,7 +257,6 @@ Change parameter type Yes [2]_ [4]_ No
226
257
Change return type Yes [2 ]_ [5 ]_ No
227
258
================================================== ============== ==============
228
259
229
-
230
260
.. [1 ] Your code may be broken by changes in the Symfony code. Such changes will
231
261
however be documented in the UPGRADE file.
232
262
0 commit comments