Skip to content

Commit

Permalink
minor #11522 Recommend including the package name in messages (greg0ire)
Browse files Browse the repository at this point in the history
This PR was merged into the 3.4 branch.

Discussion
----------

Recommend including the package name in messages

Version numbers, but they make more sense when you know the package
name. Most times, you will be able to figure it out from some FQCN, but
this should make things easier for everyone.

cc @nicolas-grekas who told me about this best practice

I'm unsure about whether this is the best branch for that kind of (pedantic ?) change

Commits
-------

d2cfba7 Recommend including the package name in messages
  • Loading branch information
javiereguiluz committed May 6, 2019
2 parents 5e9d9ac + d2cfba7 commit c0a88f6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions contributing/code/conventions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ A feature is marked as deprecated by adding a ``@deprecated`` phpdoc to
relevant classes, methods, properties, ...::

/**
* @deprecated since version 2.8, to be removed in 3.0. Use XXX instead.
* @deprecated since foo-org/bar-lib 2.8, to be removed in 3.0. Use XXX instead.
*/

The deprecation message should indicate the version when the class/method was
Expand All @@ -103,7 +103,7 @@ 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 on the criticality of the removal)::

@trigger_error('XXX() is deprecated since version 2.8 and will be removed in 3.0. Use XXX instead.', E_USER_DEPRECATED);
@trigger_error('XXX() is deprecated since foo-org/bar-lib 2.8 and will be removed in 3.0. Use XXX instead.', E_USER_DEPRECATED);

Without the `@-silencing operator`_, users would need to opt-out from deprecation
notices. Silencing swaps this behavior and allows users to opt-in when they are
Expand Down
2 changes: 1 addition & 1 deletion contributing/code/standards.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ short example containing most features described below::
*/
public function someDeprecatedMethod()
{
@trigger_error(sprintf('The %s() method is deprecated since version 2.8 and will be removed in 3.0. Use Acme\Baz::someMethod() instead.', __METHOD__), E_USER_DEPRECATED);
@trigger_error(sprintf('The %s() method is deprecated since foo-org/bar-lib 2.8 and will be removed in 3.0. Use Acme\Baz::someMethod() instead.', __METHOD__), E_USER_DEPRECATED);

return Baz::someMethod();
}
Expand Down
6 changes: 3 additions & 3 deletions service_container/alias_private.rst
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ or you decided not to maintain it anymore), you can deprecate its definition:
.. code-block:: yaml
AppBundle\Service\OldService:
deprecated: The "%service_id%" service is deprecated since 2.8 and will be removed in 3.0.
deprecated: The "%service_id%" service is deprecated since foo-org/bar-bundle 2.8 and will be removed in 3.0.
.. code-block:: xml
Expand All @@ -252,7 +252,7 @@ or you decided not to maintain it anymore), you can deprecate its definition:
<services>
<service id="AppBundle\Service\OldService">
<deprecated>The "%service_id%" service is deprecated since 2.8 and will be removed in 3.0.</deprecated>
<deprecated>The "%service_id%" service is deprecated since foo-org/bar-bundle 2.8 and will be removed in 3.0.</deprecated>
</service>
</services>
</container>
Expand All @@ -265,7 +265,7 @@ or you decided not to maintain it anymore), you can deprecate its definition:
->register(OldService::class)
->setDeprecated(
true,
'The "%service_id%" service is deprecated since 2.8 and will be removed in 3.0.'
'The "%service_id%" service is deprecated since foo-org/bar-bundle 2.8 and will be removed in 3.0.'
)
;
Expand Down

0 comments on commit c0a88f6

Please sign in to comment.