Skip to content

Commit

Permalink
[docs] Update NS of \core\deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Feb 27, 2024
1 parent 3a7da99 commit 7d8da43
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
14 changes: 7 additions & 7 deletions docs/apis/core/deprecation/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ When deprecating a code feature, it is often desirable to include a reasonable a

In some cases it is also desirable to check if a called class, or method, has been marked as deprecated.

One way to simplify this is through use of the `\core\deprecated` PHP attribute, which can be used in conjunction with the `\core\deprecation` class.
One way to simplify this is through use of the `\core\attribute\deprecated` PHP attribute, which can be used in conjunction with the `\core\deprecation` class.

:::note

Expand All @@ -41,15 +41,15 @@ The attribute is a Moodle PHP Attribute and can be applied to:

```php title="Example attribute usage"
// On a global function:
#[\core\deprecated('random_bytes', since: '4.3')]
#[\core\attribute\deprecated('random_bytes', since: '4.3')]
function random_bytes_emulate($length) {
// Replaced by random_bytes since Moodle 4.3.
}

// On a class:
#[\core\deprecated(replacement: null, since: '4.4', reason: 'This functionality has been removed.')]
#[\core\attribute\deprecated(replacement: null, since: '4.4', reason: 'This functionality has been removed.')]
class example {
#[\core\deprecated(
#[\core\attribute\deprecated(
replacement: '\core\example::do_something',
since: '4.3',
reason: 'No longer required',
Expand All @@ -60,7 +60,7 @@ class example {

// On an enum case:
enum example {
#[\core\deprecated('example::OPTION', since: '4.4', final: true)]
#[\core\attribute\deprecated('example::OPTION', since: '4.4', final: true)]
case OPTION;
}
```
Expand All @@ -76,15 +76,15 @@ The `\core\deprecation` class contains helper methods to inspect for use of the
```php title="Examples of usage"
// A method which has been initially deprecated, and replaced by 'random_bytes'. It should show debugging.
/** @deprecated since 4.3 */
#[\core\deprecated('random_bytes', since: '4.3')]
#[\core\attribute\deprecated('random_bytes', since: '4.3')]
function random_bytes_emulate($length) {
\core\deprecation::emit_deprecation_if_present(__FUNCTION__);
return random_bytes($length);
}

// A method which has been finally deprecated and should throw an exception.
/** @deprecated since 2.7 */
#[\core\deprecated(replacement: 'Events API', since: '2.3', final: true)]
#[\core\attribute\deprecated(replacement: 'Events API', since: '2.3', final: true)]
function add_to_log() {
\core\deprecation::emit_deprecation_if_present(__FUNCTION__);
}
Expand Down
6 changes: 3 additions & 3 deletions docs/devupdate.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ These param types have all been deprecated since Moodle 2.0.

## Introduction of `deprecated` attribute

A new `\core\deprecated` attribute, and related `\core\deprecation` class have been introduced to provide a standardised way to emit deprecation notices.
A new `\core\attribute\deprecated` attribute, and related `\core\deprecation` class have been introduced to provide a standardised way to emit deprecation notices.

The attribute can be applied to:

Expand All @@ -258,15 +258,15 @@ The `\core\deprecation` class contains helper methods to inspect for use of the
```php title="Examples of usage"
// A method which has been initially deprecated and should show debugging.
/** @deprecated since 4.3 */
#[\core\deprecated(replacement: 'random_bytes', since: '4.3')]
#[\core\attribute\deprecated(replacement: 'random_bytes', since: '4.3')]
function random_bytes_emulate($length) {
\core\deprecation::emit_deprecation_if_present(__FUNCTION__);
return random_bytes($length);
}

// A method which has been finally deprecated and should throw an exception.
/** @deprecated since 2.7 */
#[\core\deprecated(replacement: 'Events API', since: '2.3', final: true)]
#[\core\attribute\deprecated(replacement: 'Events API', since: '2.3', final: true)]
function add_to_log() {
\core\deprecation::emit_deprecation_if_present(__FUNCTION__);
}
Expand Down

0 comments on commit 7d8da43

Please sign in to comment.