@ 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.13 0.005 0.004 18.67 8.4.12 0.014 0.007 20.59 8.4.11 0.013 0.008 22.49 8.4.10 0.005 0.004 18.01 8.4.9 0.010 0.011 18.77 8.4.8 0.004 0.004 18.07 8.4.7 0.009 0.009 18.00 8.4.6 0.012 0.008 19.05 8.4.5 0.007 0.008 18.77 8.4.4 0.016 0.006 17.90 8.4.3 0.013 0.007 20.55 8.4.2 0.007 0.010 22.57 8.4.1 0.005 0.003 23.76 8.3.26 0.007 0.002 16.95 8.3.25 0.013 0.007 19.11 8.3.24 0.011 0.009 16.89 8.3.23 0.010 0.010 16.93 8.3.22 0.013 0.007 17.14 8.3.21 0.012 0.010 17.07 8.3.20 0.002 0.007 16.86 8.3.19 0.004 0.004 17.15 8.3.18 0.012 0.009 16.90 8.3.17 0.004 0.004 17.11 8.3.16 0.000 0.019 16.94 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.29 0.006 0.013 20.66 8.2.28 0.009 0.010 18.75 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.33 0.011 0.009 21.96 8.1.32 0.005 0.003 16.34 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 ace vim emacs key bindings
34.64 ms | 403 KiB | 5 Q