Skip to content

Commit e14e194

Browse files
committed
minor #5840 [Contributing] [Standards] Add note about trigger_error() and deprecation messages (phansys)
This PR was merged into the 2.3 branch. Discussion ---------- [Contributing] [Standards] Add note about `trigger_error()` and deprecation messages | Q | A | ------------- | --- | Doc fix? | no | New docs? | no | Applies to | 2.3+ | Fixed tickets | Add note and example on how to trigger proper deprecation messages. Related to #5525. Commits ------- 4c2f1fb [Contributing] [Standards] Add note about `trigger_error()` and deprecation messages
2 parents 71b9811 + 4c2f1fb commit e14e194

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

contributing/code/standards.rst

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,18 @@ example containing most features described below:
5050
$this->fooBar = $this->transformText($dummy);
5151
}
5252
53+
/**
54+
* @return string
55+
*
56+
* @deprecated
57+
*/
58+
public function someDeprecatedMethod()
59+
{
60+
@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);
61+
62+
return Baz::someMethod();
63+
}
64+
5365
/**
5466
* Transforms the input given as first argument.
5567
*
@@ -151,7 +163,11 @@ Structure
151163
* Use parentheses when instantiating classes regardless of the number of
152164
arguments the constructor has;
153165

154-
* Exception message strings should be concatenated using :phpfunction:`sprintf`.
166+
* Exception and error message strings should be concatenated using :phpfunction:`sprintf`.
167+
168+
* Calls to :phpfunction:`trigger_error` with type ``E_USER_DEPRECATED`` should be
169+
switched to opt-in via ``@`` operator.
170+
Read more at :ref:`contributing-code-conventions-deprecations`;
155171

156172
Naming Conventions
157173
------------------

0 commit comments

Comments
 (0)