|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2011-08-31 22:14 UTC] info at strictcoding dot co dot uk
Description:
------------
When used without ReflectionProperty::IS_STATIC, ReflectionClass::getProperties()
still returns static properties.
Test script:
---------------
class A {
public static $x;
}
$r = new ReflectionClass('A');
print_r($r->getProperties(ReflectionProperty::IS_PUBLIC));
Expected result:
----------------
Array
(
)
Actual result:
--------------
Array
(
[0] => ReflectionProperty Object
(
[name] => x
[class] => A
)
)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Mon Jan 05 10:00:02 2026 UTC |
A static property is also a public property. I can see where you are coming from but I'm not sure I want to follow the logic. Maybe we'd need "negative" filters, while this makes it quite complex so I'd then again prefer filtering it from the outside. As then you really have all the freedom. $non_private_properties = array_filter($r->getProperties(), function ($p) { return !$p->isPublic(); });