Add magic set, isset, and unset to wpdb. props pento.

These magic methods allow us to mark properties as protected or private, without breaking compatibility, as they were once accessible. The joys of PHP4.

fixes #18510.



git-svn-id: https://develop.svn.wordpress.org/trunk@21512 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin 2012-08-14 20:26:04 +00:00
parent 69881dfee7
commit c653147d47
1 changed files with 40 additions and 4 deletions

View File

@ -565,14 +565,50 @@ class wpdb {
*
* @since 3.5.0
*
* @param string $var The private member to get, and optionally process
* @param string $name The private member to get, and optionally process
* @return mixed The private member
*/
function __get( $var ) {
if ( 'col_info' == $var )
function __get( $name ) {
if ( 'col_info' == $name )
$this->load_col_info();
return $this->$var;
return $this->$name;
}
/**
* Magic function, for backwards compatibility
*
* @since 3.5.0
*
* @param string $name The private member to set
* @param mixed $value The value to set
*/
function __set( $name, $value ) {
$this->$name = $value;
}
/**
* Magic function, for backwards compatibility
*
* @since 3.5.0
*
* @param string $name The private member to check
*
* @return bool If the member is set or not
*/
function __isset( $name ) {
return isset( $this->$name );
}
/**
* Magic function, for backwards compatibility
*
* @since 3.5.0
*
* @param string $name The private member to unset
*/
function __unset( $name ) {
unset( $this->$name );
}
/**