Bug #69804 [NEW]: ReflectionClass::getStaticPropertyValue() throws exception on protected props

From: Date: Thu, 11 Jun 2015 22:19:26 +0000
Subject: Bug #69804 [NEW]: ReflectionClass::getStaticPropertyValue() throws exception on protected props
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-193345@lists.php.net to get a copy of this message
From:             grzegorz129 at gmail dot com
Operating system: OSX, Linux
PHP version:      7.0Git-2015-06-11 (snap)
Package:          Reflection related
Bug Type:         Bug
Bug description:ReflectionClass::getStaticPropertyValue() throws exception on protected props

Description:
------------
Trying to use ReflectionClass::getStaticPropertyValue() on protected
static properties of class results in exception with information about
non existing property. However ReflectionClass::getStaticProperties()
returns that property with correct value on all supported PHP versions.
Adding ReflectionProperty::setAccessible(true) doesn't affect final
effect.

Of course I can use getStaticProperties() array, but maybe
getStaticPropertyValue() should be fixed or at least some documentation
note be added?

After research I found it's related to #54620, but maybe setAccessible()
should also affect getStaticPropertyValue() call?

Test script:
---------------
<?php

class foo {
    protected static $test = 'bar';
}

$classReflection = new ReflectionClass('foo');
$property = $classReflection->getProperty('test');
var_dump($property);

$property->setAccessible(true); //Changes nothing in that case
var_dump($classReflection->getStaticProperties());
var_dump($classReflection->getStaticPropertyValue('test'));

Actual result:
--------------
http://3v4l.org/om1lZ

-- 
Edit bug report at https://bugs.php.net/bug.php?id=69804&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=69804&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=69804&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=69804&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=69804&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=69804&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=69804&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=69804&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=69804&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=69804&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=69804&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=69804&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=69804&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=69804&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69804&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=69804&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=69804&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=69804&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=69804&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=69804&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=69804&r=mysqlcfg



Thread (5 messages)

« previous php.bugs (#193345) next »