<?php
class With_Magic_Methods {
private $_args;
protected $compat_fields = array( '_args' );
public function __get( $name ) {
if ( in_array( $name, $this->compat_fields, true ) ) {
return $this->$name;
}
}
public function __set( $name, $value ) {
if ( in_array( $name, $this->compat_fields, true ) ) {
return $this->$name = $value;
}
}
public function __isset( $name ) {
if ( in_array( $name, $this->compat_fields, true ) ) {
return isset( $this->$name );
}
return false;
}
public function __unset( $name ) {
if ( in_array( $name, $this->compat_fields, true ) ) {
unset( $this->$name );
}
}
}
class No_Magic_Methods {
public $_args;
}
class WP_31_Version {
/**
* Various information about the current table
*
* @since 3.1.0
* @var array
* @access private
*/
var $_args;
/**
* Constructor. The child class should call this constructor from it's own constructor
*
* @param array $args An associative array with information about the current table
* @access protected
*/
function WP_List_Table( $args = array() ) {}
}
$wp_31_version = new WP_31_Version();
$current = new With_Magic_Methods();
$option2 = new No_Magic_Methods();
function _get() {
global $wp_31_version, $current, $option2;
echo "- - - - - - - - - - -\n";
echo "π Defined property: \n";
echo "- - - - - - - - - - -\n";
echo "πΈ WP 3.1 code: ";
var_dump( $wp_31_version->_args );
echo "\nπΈ Current code: ";
var_dump( $current->_args );
echo "\nπΈ Option 2: ";
var_dump( $option2->_args );
echo "\n- - - - - - - - - - -\n";
echo "π Dynamic property: \n";
echo "- - - - - - - - - - -\n";
echo "πΈ WP 3.1 code: ";
var_dump( $wp_31_version->_dynamic_property );
echo "\nπΈ Current code: ";
var_dump( $current->_dynamic_property );
echo "\nπΈ Option 2: ";
var_dump( $option2->_dynamic_property );
}
function test_get( $message = '' ) {
echo "*********************\n";
printf( "πΆπΆ Test get%s πΆπΆ\n", $message );
echo "*********************\n\n";
_get();
echo "\n\n";
}
function test_isset( $message = '' ) {
global $wp_31_version, $current, $option2;
echo "*********************\n";
printf( "πΆπΆ Test isset()%s πΆπΆ\n", $message );
echo "*********************\n\n";
echo "- - - - - - - - - - -\n";
echo "π Defined property: \n";
echo "- - - - - - - - - - -\n";
echo "πΈ WP 3.1 code: ";
var_dump( isset( $wp_31_version->_args ) );
echo "\nπΈ Current code: ";
var_dump( isset( $current->_args ) );
echo "\nπΈ Option 2: ";
var_dump( isset( $option2->_args ) );
echo "\n- - - - - - - - - - -\n";
echo "π Dynamic property: \n";
echo "- - - - - - - - - - -\n";
echo "πΈ WP 3.1 code: ";
var_dump( isset( $wp_31_version->_dynamic_property ) );
echo "\nπΈ Current code: ";
var_dump( isset( $current->_dynamic_property ) );
echo "\nπΈ Option 2: ";
var_dump( isset( $option2->_dynamic_property ) );
echo "\n\n";
}
function test_set( $message = '' ) {
global $wp_31_version, $current, $option2;
$new_value = array( 'test' );
$wp_31_version->_args = $new_value;
$wp_31_version->_dynamic_property = $new_value;
$current->_args = $new_value;
$current->_dynamic_property = $new_value;
$option2->_args = $new_value;
$option2->_dynamic_property = $new_value;
echo "*********************\n";
printf( "πΆπΆ Test set%s πΆπΆ\n\n", $message );
echo "*********************\n";
_get();
echo "\n\n";
}
echo "\n ***** COMPARE WITH WP 3.1 WP_List_Table ***** \n\n";
test_get();
test_isset();
test_set();
// Unset.
unset( $wp_31_version->_args );
unset( $wp_31_version->_dynamic_property );
unset( $current->_args );
unset( $current->_dynamic_property );
unset( $option2->_args );
unset( $option2->_dynamic_property );
test_get( ' after unset()' );
test_isset( ' after unset()' );
test_set( ' after unset()' );
test_isset( ' after unset() and set' );
run_test();
- Output for 8.2.10 - 8.2.26, 8.3.0 - 8.3.14, 8.4.1
- ***** COMPARE WITH WP 3.1 WP_List_Table *****
*********************
πΆπΆ Test get πΆπΆ
*********************
- - - - - - - - - - -
π Defined property:
- - - - - - - - - - -
πΈ WP 3.1 code: NULL
πΈ Current code: NULL
πΈ Option 2: NULL
- - - - - - - - - - -
π Dynamic property:
- - - - - - - - - - -
πΈ WP 3.1 code:
Warning: Undefined property: WP_31_Version::$_dynamic_property in /in/DZnjf on line 79
NULL
πΈ Current code: NULL
πΈ Option 2:
Warning: Undefined property: No_Magic_Methods::$_dynamic_property in /in/DZnjf on line 83
NULL
*********************
πΆπΆ Test isset() πΆπΆ
*********************
- - - - - - - - - - -
π Defined property:
- - - - - - - - - - -
πΈ WP 3.1 code: bool(false)
πΈ Current code: bool(false)
πΈ Option 2: bool(false)
- - - - - - - - - - -
π Dynamic property:
- - - - - - - - - - -
πΈ WP 3.1 code: bool(false)
πΈ Current code: bool(false)
πΈ Option 2: bool(false)
Deprecated: Creation of dynamic property WP_31_Version::$_dynamic_property is deprecated in /in/DZnjf on line 129
Deprecated: Creation of dynamic property No_Magic_Methods::$_dynamic_property is deprecated in /in/DZnjf on line 133
*********************
πΆπΆ Test set πΆπΆ
*********************
- - - - - - - - - - -
π Defined property:
- - - - - - - - - - -
πΈ WP 3.1 code: array(1) {
[0]=>
string(4) "test"
}
πΈ Current code: array(1) {
[0]=>
string(4) "test"
}
πΈ Option 2: array(1) {
[0]=>
string(4) "test"
}
- - - - - - - - - - -
π Dynamic property:
- - - - - - - - - - -
πΈ WP 3.1 code: array(1) {
[0]=>
string(4) "test"
}
πΈ Current code: NULL
πΈ Option 2: array(1) {
[0]=>
string(4) "test"
}
*********************
πΆπΆ Test get after unset() πΆπΆ
*********************
- - - - - - - - - - -
π Defined property:
- - - - - - - - - - -
πΈ WP 3.1 code:
Warning: Undefined property: WP_31_Version::$_args in /in/DZnjf on line 69
NULL
πΈ Current code:
Warning: Undefined property: With_Magic_Methods::$_args in /in/DZnjf on line 9
NULL
πΈ Option 2:
Warning: Undefined property: No_Magic_Methods::$_args in /in/DZnjf on line 73
NULL
- - - - - - - - - - -
π Dynamic property:
- - - - - - - - - - -
πΈ WP 3.1 code:
Warning: Undefined property: WP_31_Version::$_dynamic_property in /in/DZnjf on line 79
NULL
πΈ Current code: NULL
πΈ Option 2:
Warning: Undefined property: No_Magic_Methods::$_dynamic_property in /in/DZnjf on line 83
NULL
*********************
πΆπΆ Test isset() after unset() πΆπΆ
*********************
- - - - - - - - - - -
π Defined property:
- - - - - - - - - - -
πΈ WP 3.1 code: bool(false)
πΈ Current code: bool(false)
πΈ Option 2: bool(false)
- - - - - - - - - - -
π Dynamic property:
- - - - - - - - - - -
πΈ WP 3.1 code: bool(false)
πΈ Current code: bool(false)
πΈ Option 2: bool(false)
Deprecated: Creation of dynamic property WP_31_Version::$_dynamic_property is deprecated in /in/DZnjf on line 129
Deprecated: Creation of dynamic property No_Magic_Methods::$_dynamic_property is deprecated in /in/DZnjf on line 133
*********************
πΆπΆ Test set after unset() πΆπΆ
*********************
- - - - - - - - - - -
π Defined property:
- - - - - - - - - - -
πΈ WP 3.1 code: array(1) {
[0]=>
string(4) "test"
}
πΈ Current code: array(1) {
[0]=>
string(4) "test"
}
πΈ Option 2: array(1) {
[0]=>
string(4) "test"
}
- - - - - - - - - - -
π Dynamic property:
- - - - - - - - - - -
πΈ WP 3.1 code: array(1) {
[0]=>
string(4) "test"
}
πΈ Current code: NULL
πΈ Option 2: array(1) {
[0]=>
string(4) "test"
}
*********************
πΆπΆ Test isset() after unset() and set πΆπΆ
*********************
- - - - - - - - - - -
π Defined property:
- - - - - - - - - - -
πΈ WP 3.1 code: bool(true)
πΈ Current code: bool(true)
πΈ Option 2: bool(true)
- - - - - - - - - - -
π Dynamic property:
- - - - - - - - - - -
πΈ WP 3.1 code: bool(true)
πΈ Current code: bool(false)
πΈ Option 2: bool(true)
Fatal error: Uncaught Error: Call to undefined function run_test() in /in/DZnjf:162
Stack trace:
#0 {main}
thrown in /in/DZnjf on line 162
Process exited with code 255. - Output for 8.1.20 - 8.1.31
- ***** COMPARE WITH WP 3.1 WP_List_Table *****
*********************
πΆπΆ Test get πΆπΆ
*********************
- - - - - - - - - - -
π Defined property:
- - - - - - - - - - -
πΈ WP 3.1 code: NULL
πΈ Current code: NULL
πΈ Option 2: NULL
- - - - - - - - - - -
π Dynamic property:
- - - - - - - - - - -
πΈ WP 3.1 code:
Warning: Undefined property: WP_31_Version::$_dynamic_property in /in/DZnjf on line 79
NULL
πΈ Current code: NULL
πΈ Option 2:
Warning: Undefined property: No_Magic_Methods::$_dynamic_property in /in/DZnjf on line 83
NULL
*********************
πΆπΆ Test isset() πΆπΆ
*********************
- - - - - - - - - - -
π Defined property:
- - - - - - - - - - -
πΈ WP 3.1 code: bool(false)
πΈ Current code: bool(false)
πΈ Option 2: bool(false)
- - - - - - - - - - -
π Dynamic property:
- - - - - - - - - - -
πΈ WP 3.1 code: bool(false)
πΈ Current code: bool(false)
πΈ Option 2: bool(false)
*********************
πΆπΆ Test set πΆπΆ
*********************
- - - - - - - - - - -
π Defined property:
- - - - - - - - - - -
πΈ WP 3.1 code: array(1) {
[0]=>
string(4) "test"
}
πΈ Current code: array(1) {
[0]=>
string(4) "test"
}
πΈ Option 2: array(1) {
[0]=>
string(4) "test"
}
- - - - - - - - - - -
π Dynamic property:
- - - - - - - - - - -
πΈ WP 3.1 code: array(1) {
[0]=>
string(4) "test"
}
πΈ Current code: NULL
πΈ Option 2: array(1) {
[0]=>
string(4) "test"
}
*********************
πΆπΆ Test get after unset() πΆπΆ
*********************
- - - - - - - - - - -
π Defined property:
- - - - - - - - - - -
πΈ WP 3.1 code:
Warning: Undefined property: WP_31_Version::$_args in /in/DZnjf on line 69
NULL
πΈ Current code:
Warning: Undefined property: With_Magic_Methods::$_args in /in/DZnjf on line 9
NULL
πΈ Option 2:
Warning: Undefined property: No_Magic_Methods::$_args in /in/DZnjf on line 73
NULL
- - - - - - - - - - -
π Dynamic property:
- - - - - - - - - - -
πΈ WP 3.1 code:
Warning: Undefined property: WP_31_Version::$_dynamic_property in /in/DZnjf on line 79
NULL
πΈ Current code: NULL
πΈ Option 2:
Warning: Undefined property: No_Magic_Methods::$_dynamic_property in /in/DZnjf on line 83
NULL
*********************
πΆπΆ Test isset() after unset() πΆπΆ
*********************
- - - - - - - - - - -
π Defined property:
- - - - - - - - - - -
πΈ WP 3.1 code: bool(false)
πΈ Current code: bool(false)
πΈ Option 2: bool(false)
- - - - - - - - - - -
π Dynamic property:
- - - - - - - - - - -
πΈ WP 3.1 code: bool(false)
πΈ Current code: bool(false)
πΈ Option 2: bool(false)
*********************
πΆπΆ Test set after unset() πΆπΆ
*********************
- - - - - - - - - - -
π Defined property:
- - - - - - - - - - -
πΈ WP 3.1 code: array(1) {
[0]=>
string(4) "test"
}
πΈ Current code: array(1) {
[0]=>
string(4) "test"
}
πΈ Option 2: array(1) {
[0]=>
string(4) "test"
}
- - - - - - - - - - -
π Dynamic property:
- - - - - - - - - - -
πΈ WP 3.1 code: array(1) {
[0]=>
string(4) "test"
}
πΈ Current code: NULL
πΈ Option 2: array(1) {
[0]=>
string(4) "test"
}
*********************
πΆπΆ Test isset() after unset() and set πΆπΆ
*********************
- - - - - - - - - - -
π Defined property:
- - - - - - - - - - -
πΈ WP 3.1 code: bool(true)
πΈ Current code: bool(true)
πΈ Option 2: bool(true)
- - - - - - - - - - -
π Dynamic property:
- - - - - - - - - - -
πΈ WP 3.1 code: bool(true)
πΈ Current code: bool(false)
πΈ Option 2: bool(true)
Fatal error: Uncaught Error: Call to undefined function run_test() in /in/DZnjf:162
Stack trace:
#0 {main}
thrown in /in/DZnjf on line 162
Process exited with code 255.
preferences:
59.59 ms | 422 KiB | 5 Q