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: http://core.svn.wordpress.org/trunk@21512 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Nacin 2012-08-14 20:26:04 +00:00
parent c11a4c09e8
commit f965d758fc
1 changed files with 40 additions and 4 deletions

View File

@ -565,14 +565,50 @@ class wpdb {
* *
* @since 3.5.0 * @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 * @return mixed The private member
*/ */
function __get( $var ) { function __get( $name ) {
if ( 'col_info' == $var ) if ( 'col_info' == $name )
$this->load_col_info(); $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 );
} }
/** /**