mirror of
git://develop.git.wordpress.org/
synced 2025-04-15 17:45:04 +02:00
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
This commit is contained in:
parent
1fc10c92a2
commit
9e4188b93b
@ -187,8 +187,8 @@ class WP_List_Table {
|
||||
}
|
||||
|
||||
trigger_error(
|
||||
"The property `{$name}` is not defined. Getting a dynamic (undefined) property is " .
|
||||
'deprecated since version 6.4.0! Instead, define the property on the class.',
|
||||
"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
|
||||
);
|
||||
return null;
|
||||
@ -210,8 +210,8 @@ class WP_List_Table {
|
||||
}
|
||||
|
||||
trigger_error(
|
||||
"The property `{$name}` is not defined. Setting a dynamic (undefined) property is " .
|
||||
'deprecated since version 6.4.0! Instead, define the property on the class.',
|
||||
"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
|
||||
);
|
||||
}
|
||||
@ -231,8 +231,8 @@ class WP_List_Table {
|
||||
}
|
||||
|
||||
trigger_error(
|
||||
"The property `{$name}` is not defined. Checking `isset()` on a dynamic (undefined) property " .
|
||||
'is deprecated since version 6.4.0! Instead, define the property on the class.',
|
||||
"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
|
||||
);
|
||||
return false;
|
||||
@ -253,8 +253,8 @@ class WP_List_Table {
|
||||
}
|
||||
|
||||
trigger_error(
|
||||
"A property `{$name}` is not defined. Unsetting a dynamic (undefined) property is " .
|
||||
'deprecated since version 6.4.0! Instead, define the property on the class.',
|
||||
"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
|
||||
);
|
||||
}
|
||||
|
@ -371,7 +371,7 @@ class Tests_Admin_WpListTable extends WP_UnitTestCase {
|
||||
* @param string $property_name Property name to get.
|
||||
* @param mixed $expected Expected value.
|
||||
*/
|
||||
public function test_should_get_compat_fields_defined_property( $property_name, $expected ) {
|
||||
public function test_should_get_compat_fields( $property_name, $expected ) {
|
||||
$list_table = new WP_List_Table( array( 'plural' => '_wp_tests__get' ) );
|
||||
|
||||
if ( 'screen' === $property_name ) {
|
||||
@ -389,10 +389,10 @@ class Tests_Admin_WpListTable extends WP_UnitTestCase {
|
||||
public function test_should_throw_deprecation_when_getting_dynamic_property() {
|
||||
$this->expectDeprecation();
|
||||
$this->expectDeprecationMessage(
|
||||
'The property `undefined_property` is not defined. Getting a dynamic (undefined) property is ' .
|
||||
'deprecated since version 6.4.0! Instead, define the property on the class.'
|
||||
'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.'
|
||||
);
|
||||
$this->assertNull( $this->list_table->undefined_property, 'Getting a dynamic property should return null from WP_List_Table::__get()' );
|
||||
$this->assertNull( $this->list_table->undeclared_property, 'Getting a dynamic property should return null from WP_List_Table::__get()' );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -418,10 +418,10 @@ class Tests_Admin_WpListTable extends WP_UnitTestCase {
|
||||
public function test_should_throw_deprecation_when_setting_dynamic_property() {
|
||||
$this->expectDeprecation();
|
||||
$this->expectDeprecationMessage(
|
||||
'The property `undefined_property` is not defined. Setting a dynamic (undefined) property is ' .
|
||||
'deprecated since version 6.4.0! Instead, define the property on the class.'
|
||||
'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.'
|
||||
);
|
||||
$this->list_table->undefined_property = 'some value';
|
||||
$this->list_table->undeclared_property = 'some value';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -433,7 +433,7 @@ class Tests_Admin_WpListTable extends WP_UnitTestCase {
|
||||
* @param string $property_name Property name to check.
|
||||
* @param mixed $expected Expected value.
|
||||
*/
|
||||
public function test_should_isset_compat_fields_defined_property( $property_name, $expected ) {
|
||||
public function test_should_isset_compat_fields( $property_name, $expected ) {
|
||||
$actual = isset( $this->list_table->$property_name );
|
||||
if ( is_null( $expected ) ) {
|
||||
$this->assertFalse( $actual );
|
||||
@ -450,10 +450,10 @@ class Tests_Admin_WpListTable extends WP_UnitTestCase {
|
||||
public function test_should_throw_deprecation_when_isset_of_dynamic_property() {
|
||||
$this->expectDeprecation();
|
||||
$this->expectDeprecationMessage(
|
||||
'The property `undefined_property` is not defined. Checking `isset()` on a dynamic (undefined) property ' .
|
||||
'is deprecated since version 6.4.0! Instead, define the property on the class.'
|
||||
'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.'
|
||||
);
|
||||
$this->assertFalse( isset( $this->list_table->undefined_property ), 'Checking a dyanmic property should return false from WP_List_Table::__isset()' );
|
||||
$this->assertFalse( isset( $this->list_table->undeclared_property ), 'Checking a dynamic property should return false from WP_List_Table::__isset()' );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -477,10 +477,10 @@ class Tests_Admin_WpListTable extends WP_UnitTestCase {
|
||||
public function test_should_throw_deprecation_when_unset_of_dynamic_property() {
|
||||
$this->expectDeprecation();
|
||||
$this->expectDeprecationMessage(
|
||||
'A property `undefined_property` is not defined. Unsetting a dynamic (undefined) property is ' .
|
||||
'deprecated since version 6.4.0! Instead, define the property on the class.'
|
||||
'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.'
|
||||
);
|
||||
unset( $this->list_table->undefined_property );
|
||||
unset( $this->list_table->undeclared_property );
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user