@ 2023-07-25T21:42:43Z <?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();
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).
Version System time (s) User time (s) Memory (MiB) 8.4.2 0.007 0.010 22.57 8.4.1 0.005 0.003 23.76 8.3.15 0.006 0.013 17.50 8.3.14 0.004 0.007 16.80 8.3.13 0.007 0.003 18.83 8.3.12 0.007 0.003 19.01 8.3.11 0.013 0.006 16.75 8.3.10 0.005 0.005 24.06 8.3.9 0.000 0.008 26.77 8.3.8 0.000 0.009 17.97 8.3.7 0.012 0.003 18.40 8.3.6 0.006 0.016 18.65 8.3.5 0.011 0.011 16.96 8.3.4 0.014 0.003 23.73 8.3.3 0.009 0.006 20.30 8.3.2 0.008 0.000 24.18 8.3.1 0.000 0.008 24.66 8.3.0 0.008 0.000 26.16 8.2.27 0.015 0.004 17.38 8.2.26 0.008 0.011 16.96 8.2.25 0.011 0.007 18.82 8.2.24 0.003 0.007 18.94 8.2.23 0.003 0.007 20.94 8.2.22 0.006 0.003 37.54 8.2.21 0.011 0.007 26.77 8.2.20 0.005 0.005 16.75 8.2.19 0.009 0.006 18.22 8.2.18 0.007 0.010 16.63 8.2.17 0.004 0.011 19.21 8.2.16 0.007 0.007 22.96 8.2.15 0.004 0.004 25.66 8.2.14 0.005 0.003 24.66 8.2.13 0.004 0.004 26.16 8.2.12 0.004 0.004 19.54 8.2.11 0.003 0.006 20.56 8.2.10 0.006 0.003 20.32 8.1.31 0.004 0.004 18.40 8.1.30 0.006 0.003 18.45 8.1.29 0.003 0.007 18.88 8.1.28 0.003 0.016 25.92 8.1.27 0.005 0.003 24.66 8.1.26 0.003 0.005 26.35 8.1.25 0.008 0.000 28.09 8.1.24 0.004 0.007 18.61 8.1.23 0.013 0.010 18.66 8.1.20 0.005 0.005 79.33
preferences:dark mode live preview
27.17 ms | 403 KiB | 5 Q