Skip to content

Commit 9e4188b

Browse files
Code Modernization: Use "declare" in WP_List_Table magic methods deprecation message
Changes "define" to "declare" in the deprecation message in `WP_List_Table` magic methods. Why is "declare" better? It aligns well to: * the topic of and published information about dynamic properties. * the act of explicitly listing the variable as a property on the class. The goal of this message is guide developers to change their code. Changing the term to "declare" hopefully will aid in the understanding of what is being asked of developers when this deprecation is thrown. Follow-up [56349]. Props hellofromTonya, antonvlasenko. Fixes #58896. git-svn-id: https://develop.svn.wordpress.org/trunk@56356 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 1fc10c9 commit 9e4188b

2 files changed

Lines changed: 22 additions & 22 deletions

File tree

src/wp-admin/includes/class-wp-list-table.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,8 @@ public function __get( $name ) {
187187
}
188188

189189
trigger_error(
190-
"The property `{$name}` is not defined. Getting a dynamic (undefined) property is " .
191-
'deprecated since version 6.4.0! Instead, define the property on the class.',
190+
"The property `{$name}` is not declared. Getting a dynamic property is " .
191+
'deprecated since version 6.4.0! Instead, declare the property on the class.',
192192
E_USER_DEPRECATED
193193
);
194194
return null;
@@ -210,8 +210,8 @@ public function __set( $name, $value ) {
210210
}
211211

212212
trigger_error(
213-
"The property `{$name}` is not defined. Setting a dynamic (undefined) property is " .
214-
'deprecated since version 6.4.0! Instead, define the property on the class.',
213+
"The property `{$name}` is not declared. Setting a dynamic property is " .
214+
'deprecated since version 6.4.0! Instead, declare the property on the class.',
215215
E_USER_DEPRECATED
216216
);
217217
}
@@ -231,8 +231,8 @@ public function __isset( $name ) {
231231
}
232232

233233
trigger_error(
234-
"The property `{$name}` is not defined. Checking `isset()` on a dynamic (undefined) property " .
235-
'is deprecated since version 6.4.0! Instead, define the property on the class.',
234+
"The property `{$name}` is not declared. Checking `isset()` on a dynamic property " .
235+
'is deprecated since version 6.4.0! Instead, declare the property on the class.',
236236
E_USER_DEPRECATED
237237
);
238238
return false;
@@ -253,8 +253,8 @@ public function __unset( $name ) {
253253
}
254254

255255
trigger_error(
256-
"A property `{$name}` is not defined. Unsetting a dynamic (undefined) property is " .
257-
'deprecated since version 6.4.0! Instead, define the property on the class.',
256+
"A property `{$name}` is not declared. Unsetting a dynamic property is " .
257+
'deprecated since version 6.4.0! Instead, declare the property on the class.',
258258
E_USER_DEPRECATED
259259
);
260260
}

tests/phpunit/tests/admin/wpListTable.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ public function data_get_views_links_doing_it_wrong() {
371371
* @param string $property_name Property name to get.
372372
* @param mixed $expected Expected value.
373373
*/
374-
public function test_should_get_compat_fields_defined_property( $property_name, $expected ) {
374+
public function test_should_get_compat_fields( $property_name, $expected ) {
375375
$list_table = new WP_List_Table( array( 'plural' => '_wp_tests__get' ) );
376376

377377
if ( 'screen' === $property_name ) {
@@ -389,10 +389,10 @@ public function test_should_get_compat_fields_defined_property( $property_name,
389389
public function test_should_throw_deprecation_when_getting_dynamic_property() {
390390
$this->expectDeprecation();
391391
$this->expectDeprecationMessage(
392-
'The property `undefined_property` is not defined. Getting a dynamic (undefined) property is ' .
393-
'deprecated since version 6.4.0! Instead, define the property on the class.'
392+
'The property `undeclared_property` is not declared. Getting a dynamic property is ' .
393+
'deprecated since version 6.4.0! Instead, declare the property on the class.'
394394
);
395-
$this->assertNull( $this->list_table->undefined_property, 'Getting a dynamic property should return null from WP_List_Table::__get()' );
395+
$this->assertNull( $this->list_table->undeclared_property, 'Getting a dynamic property should return null from WP_List_Table::__get()' );
396396
}
397397

398398
/**
@@ -418,10 +418,10 @@ public function test_should_set_compat_fields_defined_property( $property_name )
418418
public function test_should_throw_deprecation_when_setting_dynamic_property() {
419419
$this->expectDeprecation();
420420
$this->expectDeprecationMessage(
421-
'The property `undefined_property` is not defined. Setting a dynamic (undefined) property is ' .
422-
'deprecated since version 6.4.0! Instead, define the property on the class.'
421+
'The property `undeclared_property` is not declared. Setting a dynamic property is ' .
422+
'deprecated since version 6.4.0! Instead, declare the property on the class.'
423423
);
424-
$this->list_table->undefined_property = 'some value';
424+
$this->list_table->undeclared_property = 'some value';
425425
}
426426

427427
/**
@@ -433,7 +433,7 @@ public function test_should_throw_deprecation_when_setting_dynamic_property() {
433433
* @param string $property_name Property name to check.
434434
* @param mixed $expected Expected value.
435435
*/
436-
public function test_should_isset_compat_fields_defined_property( $property_name, $expected ) {
436+
public function test_should_isset_compat_fields( $property_name, $expected ) {
437437
$actual = isset( $this->list_table->$property_name );
438438
if ( is_null( $expected ) ) {
439439
$this->assertFalse( $actual );
@@ -450,10 +450,10 @@ public function test_should_isset_compat_fields_defined_property( $property_name
450450
public function test_should_throw_deprecation_when_isset_of_dynamic_property() {
451451
$this->expectDeprecation();
452452
$this->expectDeprecationMessage(
453-
'The property `undefined_property` is not defined. Checking `isset()` on a dynamic (undefined) property ' .
454-
'is deprecated since version 6.4.0! Instead, define the property on the class.'
453+
'The property `undeclared_property` is not declared. Checking `isset()` on a dynamic property ' .
454+
'is deprecated since version 6.4.0! Instead, declare the property on the class.'
455455
);
456-
$this->assertFalse( isset( $this->list_table->undefined_property ), 'Checking a dyanmic property should return false from WP_List_Table::__isset()' );
456+
$this->assertFalse( isset( $this->list_table->undeclared_property ), 'Checking a dynamic property should return false from WP_List_Table::__isset()' );
457457
}
458458

459459
/**
@@ -477,10 +477,10 @@ public function test_should_unset_compat_fields_defined_property( $property_name
477477
public function test_should_throw_deprecation_when_unset_of_dynamic_property() {
478478
$this->expectDeprecation();
479479
$this->expectDeprecationMessage(
480-
'A property `undefined_property` is not defined. Unsetting a dynamic (undefined) property is ' .
481-
'deprecated since version 6.4.0! Instead, define the property on the class.'
480+
'A property `undeclared_property` is not declared. Unsetting a dynamic property is ' .
481+
'deprecated since version 6.4.0! Instead, declare the property on the class.'
482482
);
483-
unset( $this->list_table->undefined_property );
483+
unset( $this->list_table->undeclared_property );
484484
}
485485

486486
/**

0 commit comments

Comments
 (0)