note 105417 modified in reflectionclass.getstaticpropertyvalue by danbrown

From: Date: Wed, 17 Aug 2011 15:35:30 +0000
Subject: note 105417 modified in reflectionclass.getstaticpropertyvalue by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-182534@lists.php.net to get a copy of this message
It seems this method has a security level different from the getStaticProperties method. If you make two classes A and B looking like <?php class A{ protected static $static_var='foo'; public function getStatic(){ $class=new ReflectionClass($this); return $class->getStaticPropertyValue('static_var'); } public function getStatic2(){ $class=new ReflectionClass($this); $staticProps=$class->getStaticProperties(); return $staticProps['static_var']; } public function __construct(){ echo $this->getStatic2(); echo $this->getStatic(); } } class B extends A{ protected static $static_var='foo2'; } ?> Then the output will be an exception for the getStatic() call, when the getStatic2() will correctly return 'foo2'; --was-- It seems this method has a security level different from the getStaticProperties method. If you make two classes A and B looking like class A{ protected static $static_var='foo'; public function getStatic(){ $class=new ReflectionClass($this); return $class->getStaticPropertyValue('static_var'); } public function getStatic2(){ $class=new ReflectionClass($this); $staticProps=$class->getStaticProperties(); return $staticProps['static_var']; } public function __construct(){ echo $this->getStatic2(); echo $this->getStatic(); } } class B extends A{ protected static $static_var='foo2'; } Then the output will be an exception for the getStatic() call, when the getStatic2() will correctly return 'foo2'; http://php.net/manual/en/reflectionclass.getstaticpropertyvalue.php

« previous php.notes (#182534) next »