From db079408d7dfcfcd049f5abc612c3bb4b5e37daa Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Thu, 31 Mar 2011 11:42:05 +1300 Subject: [PATCH] Add __get()/__isset() so private/protected properties are read-only. Signed-off-by: Andrew McMillan --- inc/Principal.php | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/inc/Principal.php b/inc/Principal.php index 8ececd1b..8384dce5 100644 --- a/inc/Principal.php +++ b/inc/Principal.php @@ -91,7 +91,7 @@ class Principal { protected $by_email; /** - * If we're using memcached these is the namespace we'll put stuff in + * If we're using memcached this is the namespace we'll put stuff in * @var unknown_type */ private $cacheNs; @@ -114,6 +114,27 @@ class Principal { break; } + + /** + * This will allow protected properties to be referenced for retrieval, but not + * referenced for update. + * @param $property + */ + function __get( $property ) { + return $this->{$property}; + } + + + /** + * This will allow protected properties to be examined for whether they are set + * without making them writable. PHP 5.1 or later only. + * @param $property + */ + function __isset( $property ) { + return isset($this->{$property}); + } + + $cache = new AwlCache(); if ( $use_cache && isset($session->principal_id) ) { switch ( $type ) {