#37816 [Fbk->Opn]: REflectionProperty does not throw exception when accessing protected attribute
| From: | pierrealain dot bourdil at free dot fr | Date: | Thu, 15 Jun 2006 12:12:53 +0000 |
| Subject: | #37816 [Fbk->Opn]: REflectionProperty does not throw exception when accessing protected attribute | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-98393@lists.php.net to get a copy of this message | ||
ID: 37816
User updated by: pierrealain dot bourdil at free dot fr
Reported By: pierrealain dot bourdil at free dot fr
-Status: Feedback
+Status: Open
Bug Type: Class/Object related
Operating System: gento
PHP Version: 5.1.4
New Comment:
bjori, the script is at
http://pastebin.com/710566
best regards
Previous Comments:
------------------------------------------------------------------------
[2006-06-15 11:22:46] bjori@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves.
A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external
resources such as databases, etc.
If possible, make the script source available online and provide
an URL to it here. Try to avoid embedding huge scripts into the report.
------------------------------------------------------------------------
[2006-06-15 11:05:22] pierrealain dot bourdil at free dot fr
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 this bug report at http://bugs.php.net/?id=37816&edit=1