Skip to content

Commit

Permalink
Code Modernization: Use wp_trigger_error() in WP_Text_Diff_Renderer_T…
Browse files Browse the repository at this point in the history
…able magic methods.

Replaces `trigger_error()` with `wp_trigger_error()` in each of the `WP_Text_Diff_Renderer_Table` magic methods.

[56354] added the dynamic properties deprecation messages to the `__get()`, `__set()`, `__isset()`, `__unset()` magic methods. Since that commit, `wp_trigger_error()` was introduced (see [56530]) as a wrapper for `trigger_error()`.

Follow-up to [56354], [56530].

See #58898, #57686.

git-svn-id: https://develop.svn.wordpress.org/trunk@56544 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
hellofromtonya committed Sep 7, 2023
1 parent a5eddea commit 9de4142
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/wp-includes/class-wp-text-diff-renderer-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,8 @@ public function __get( $name ) {
return $this->$name;
}

trigger_error(
wp_trigger_error(
__METHOD__,
"The property `{$name}` is not declared. Getting a dynamic property is " .
'deprecated since version 6.4.0! Instead, declare the property on the class.',
E_USER_DEPRECATED
Expand All @@ -544,7 +545,8 @@ public function __set( $name, $value ) {
return;
}

trigger_error(
wp_trigger_error(
__METHOD__,
"The property `{$name}` is not declared. Setting a dynamic property is " .
'deprecated since version 6.4.0! Instead, declare the property on the class.',
E_USER_DEPRECATED
Expand All @@ -565,7 +567,8 @@ public function __isset( $name ) {
return isset( $this->$name );
}

trigger_error(
wp_trigger_error(
__METHOD__,
"The property `{$name}` is not declared. Checking `isset()` on a dynamic property " .
'is deprecated since version 6.4.0! Instead, declare the property on the class.',
E_USER_DEPRECATED
Expand All @@ -587,7 +590,8 @@ public function __unset( $name ) {
return;
}

trigger_error(
wp_trigger_error(
__METHOD__,
"A property `{$name}` is not declared. Unsetting a dynamic property is " .
'deprecated since version 6.4.0! Instead, declare the property on the class.',
E_USER_DEPRECATED
Expand Down
4 changes: 4 additions & 0 deletions tests/phpunit/tests/diff/wpTextDiffRendererTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public function test_should_get_compat_fields( $property_name, $expected ) {
public function test_should_throw_deprecation_when_getting_dynamic_property() {
$this->expectDeprecation();
$this->expectDeprecationMessage(
'WP_Text_Diff_Renderer_Table::__get(): ' .
'The property `undeclared_property` is not declared. Getting a dynamic property is ' .
'deprecated since version 6.4.0! Instead, declare the property on the class.'
);
Expand Down Expand Up @@ -72,6 +73,7 @@ public function test_should_set_compat_fields( $property_name ) {
public function test_should_throw_deprecation_when_setting_dynamic_property() {
$this->expectDeprecation();
$this->expectDeprecationMessage(
'WP_Text_Diff_Renderer_Table::__set(): ' .
'The property `undeclared_property` is not declared. Setting a dynamic property is ' .
'deprecated since version 6.4.0! Instead, declare the property on the class.'
);
Expand Down Expand Up @@ -104,6 +106,7 @@ public function test_should_isset_compat_fields( $property_name, $expected ) {
public function test_should_throw_deprecation_when_isset_of_dynamic_property() {
$this->expectDeprecation();
$this->expectDeprecationMessage(
'WP_Text_Diff_Renderer_Table::__isset(): ' .
'The property `undeclared_property` is not declared. Checking `isset()` on a dynamic property ' .
'is deprecated since version 6.4.0! Instead, declare the property on the class.'
);
Expand Down Expand Up @@ -131,6 +134,7 @@ public function test_should_unset_compat_fields( $property_name ) {
public function test_should_throw_deprecation_when_unset_of_dynamic_property() {
$this->expectDeprecation();
$this->expectDeprecationMessage(
'WP_Text_Diff_Renderer_Table::__unset(): ' .
'A property `undeclared_property` is not declared. Unsetting a dynamic property is ' .
'deprecated since version 6.4.0! Instead, declare the property on the class.'
);
Expand Down

0 comments on commit 9de4142

Please sign in to comment.