From: denis at edistar dot com
Operating system: Linux
PHP version: 5.1.2
PHP Bug Type: Class/Object related
Bug description: ReflectionProperty fails to return correct visibility
Description:
------------
I have a base abstract class that defines a property to be
protected and that also checks this runtime using the
reflection api.
My purpose is to enforce the extending class to declare
that property as protected too.
The reflection api returns me wrong information. It
returns always that the property is protected (as defined
in the base class), ignoring the definition of the
extending class.
Reproduce code:
---------------
abstract class enum {
protected $_values;
public function __construct() {
$property = new ReflectionProperty(get_class($this),'_values');
if(!$property->isProtected()) {
throw new Exception("Property _values must be declared as
protected");
}
}
}
final class myEnum extends enum {
public $_values = array(
0 => 'No value',
1 => 'Value n.1',
2 => 'Value n.2',
4 => 'Value n.4'
);
}
$x = new myEnum();
Expected result:
----------------
Fatal error: Uncaught exception 'Exception' with message
'Property _values must be declared as protected'
Actual result:
--------------
No exception is thrown
--
Edit bug report at http://bugs.php.net/?id=36337&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=36337&r=trysnapshot44
Try a CVS snapshot (PHP 5.1):
http://bugs.php.net/fix.php?id=36337&r=trysnapshot51
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=36337&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=36337&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=36337&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=36337&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=36337&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=36337&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=36337&r=support
Expected behavior: http://bugs.php.net/fix.php?id=36337&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=36337&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=36337&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=36337&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=36337&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=36337&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=36337&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=36337&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=36337&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=36337&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=36337&r=mysqlcfg