#37816 [NEW]: REflectionProperty does not throw exception when accessing protected attribute

From: Date: Thu, 15 Jun 2006 11:05:22 +0000
Subject: #37816 [NEW]: REflectionProperty does not throw exception when accessing protected attribute
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-98389@lists.php.net to get a copy of this message
From: pierrealain dot bourdil at free dot fr Operating system: gento PHP version: 5.1.4 PHP Bug Type: Class/Object related Bug description: REflectionProperty does not throw exception when accessing protected attribute Description: ------------ First , i hope to really submit a bug, at least i've done my best to check it. i've made a class that contains other class, with dynamic adding,removing possibilities, save,restaure from session, and which use __call,__get,__set method. Within __get method, i instanciate ReflectionProperty. When i access a protected property, using ReflectionProperty->getValue, i expect to catch an exception, but i don't. I can access this property. It works perfectly with ReflectionMethod, but no with ReflectionProperty. Reproduce code: --------------- $rp=new ReflectionProperty($myClass,value); try{ if ($rp->isStatic()) return $rp->getValue(null); else return $rp->getValue(self::$instance->aClasses[$myClass]); }catch( Exception $e){ echo $e->getMessage(); return null; } now a portion the class which contains property that i tri to access protected $pp; public function __construct(){ $this->pp="pp"; } Expected result: ---------------- this is what i expect, but for method, Trying to invoke protected method test::testFunction from scope ReflectionMethod i think i would expect something like that Trying to access protected property test::pp from scope Reflectionproperty Actual result: -------------- __get : pp -- Edit bug report at http://bugs.php.net/?id=37816&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=37816&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=37816&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=37816&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=37816&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=37816&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=37816&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=37816&r=needscript Try newer version: http://bugs.php.net/fix.php?id=37816&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=37816&r=support Expected behavior: http://bugs.php.net/fix.php?id=37816&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=37816&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=37816&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=37816&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=37816&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=37816&r=dst IIS Stability: http://bugs.php.net/fix.php?id=37816&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=37816&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=37816&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=37816&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=37816&r=mysqlcfg

« previous php.bugs (#98389) next »