Skip to content

Commit 9de4142

Browse files
Code Modernization: Use wp_trigger_error() in WP_Text_Diff_Renderer_Table 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
1 parent a5eddea commit 9de4142

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/wp-includes/class-wp-text-diff-renderer-table.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,8 @@ public function __get( $name ) {
521521
return $this->$name;
522522
}
523523

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

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

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

590-
trigger_error(
593+
wp_trigger_error(
594+
__METHOD__,
591595
"A property `{$name}` is not declared. Unsetting a dynamic property is " .
592596
'deprecated since version 6.4.0! Instead, declare the property on the class.',
593597
E_USER_DEPRECATED

tests/phpunit/tests/diff/wpTextDiffRendererTable.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public function test_should_get_compat_fields( $property_name, $expected ) {
4343
public function test_should_throw_deprecation_when_getting_dynamic_property() {
4444
$this->expectDeprecation();
4545
$this->expectDeprecationMessage(
46+
'WP_Text_Diff_Renderer_Table::__get(): ' .
4647
'The property `undeclared_property` is not declared. Getting a dynamic property is ' .
4748
'deprecated since version 6.4.0! Instead, declare the property on the class.'
4849
);
@@ -72,6 +73,7 @@ public function test_should_set_compat_fields( $property_name ) {
7273
public function test_should_throw_deprecation_when_setting_dynamic_property() {
7374
$this->expectDeprecation();
7475
$this->expectDeprecationMessage(
76+
'WP_Text_Diff_Renderer_Table::__set(): ' .
7577
'The property `undeclared_property` is not declared. Setting a dynamic property is ' .
7678
'deprecated since version 6.4.0! Instead, declare the property on the class.'
7779
);
@@ -104,6 +106,7 @@ public function test_should_isset_compat_fields( $property_name, $expected ) {
104106
public function test_should_throw_deprecation_when_isset_of_dynamic_property() {
105107
$this->expectDeprecation();
106108
$this->expectDeprecationMessage(
109+
'WP_Text_Diff_Renderer_Table::__isset(): ' .
107110
'The property `undeclared_property` is not declared. Checking `isset()` on a dynamic property ' .
108111
'is deprecated since version 6.4.0! Instead, declare the property on the class.'
109112
);
@@ -131,6 +134,7 @@ public function test_should_unset_compat_fields( $property_name ) {
131134
public function test_should_throw_deprecation_when_unset_of_dynamic_property() {
132135
$this->expectDeprecation();
133136
$this->expectDeprecationMessage(
137+
'WP_Text_Diff_Renderer_Table::__unset(): ' .
134138
'A property `undeclared_property` is not declared. Unsetting a dynamic property is ' .
135139
'deprecated since version 6.4.0! Instead, declare the property on the class.'
136140
);

0 commit comments

Comments
 (0)