-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
added information about how deprecations work #2246
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,3 +76,29 @@ must be used instead (where ``XXX`` is the name of the related thing): | |
difference: "setXXX" may replace, or add new elements to the relation. | ||
"replaceXXX", on the other hand, cannot add new elements. If an unrecognized | ||
key as passed to "replaceXXX" it must throw an exception. | ||
|
||
Deprecations | ||
------------ | ||
|
||
From time to time, some classes and/or methods are deprecated in the | ||
framework; that happens when a feature implementation cannot be changed | ||
because of backward compatibility issues, but we still want to propose a | ||
"better" alternative. In that case, the old implementation can simply be | ||
**deprecated**. | ||
|
||
A feature is marked as deprecated by adding a ``@deprecated`` phpdoc to | ||
relevant classes, methods, properties, ...:: | ||
|
||
/** | ||
* @deprecated Deprecated since version 2.X, to be removed in 2.Y. Use XXX instead. | ||
*/ | ||
|
||
The deprecation message should indicate the version when the class/method was | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here? |
||
deprecated, the version when it will be removed, and whenever possible, how | ||
the feature was replaced. | ||
|
||
A PHP ``E_USER_DEPRECATED`` error must also be triggered to help people with | ||
the migration starting one or two minor versions before the version where the | ||
feature will be removed (depending of the criticality of the removal):: | ||
|
||
trigger_error('XXX() is deprecated since version 2.X and will be removed in 2.Y. Use XXX instead.', E_USER_DEPRECATED); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like to break long lines to avoid horizontal scrolling bars, we could replace this by: trigger_error(
'XXX() is deprecated since version 2.X and will be removed in 2.Y. Use XXX instead.',
E_USER_DEPRECATED
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,6 +84,15 @@ be scheduled for the next major version: Symfony 3.0. | |
The work on Symfony 3.0 will start whenever enough major features breaking | ||
backward compatibility are waiting on the todo-list. | ||
|
||
Deprecations | ||
------------ | ||
|
||
When a feature implementation cannot be replaced with a better one without | ||
breaking backward compatibility, there is still the possibility to deprecate | ||
the old implementation and add a new preferred one along side. Read the | ||
:doc:`conventions <../code/conventions>` document to learn more about how | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The link should go to the section itself instead of the beginning of the page |
||
deprecations are handled in Symfony. | ||
|
||
Rationale | ||
--------- | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And think this should also be replaced with classes, methods, properties, constants, ect.?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, as you deprecate a feature that is implemented in classes/methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get why ie constants or interfaces would not be valid cases here also
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because a feature cannot be made of constants only. You are nitpicking here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are times when we only deprecate a constant / option (ie form).
I think interfaces are at least non disputable.