Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?PHP
- class fu
- {
- protected $__defaultConfig = [];
- public function __construct()
- {
- $class = get_called_class();
- $props = [];
- do
- {
- foreach((new \ReflectionClass($class))->getDefaultProperties() as $property => $value) // <---
- {
- if(!in_array($property, ['__autoConfig', '__defaultConfig']))
- continue;
- var_dump([$class.'::'.$property => $value]);
- }
- }
- while($class = get_parent_class($class));
- /*
- // same...
- foreach($this->parents() as $class)
- {
- foreach((new \ReflectionClass($class))->getDefaultProperties() as $property => $value)
- {
- if(!in_array($property, ['__autoConfig', '__defaultConfig']))
- continue;
- var_dump([$class.'::'.$property => $value]);
- }
- }
- */
- }
- }
- class baz extends fu
- {
- protected $__defaultConfig = [];
- }
- ?>
- // actual
- array(1) {
- ["fu::__defaultConfig"]=>
- array(7) {
- ["scheme"]=>
- string(4) "http"
- ["query"]=>
- NULL
- ["fragment"]=>
- NULL
- ["protocol"]=>
- NULL
- ["auth"]=>
- NULL
- ["version"]=>
- string(3) "1.1"
- ["headers"]=>
- array(0) {
- }
- }
- }
- array(1) {
- ["baz::__defaultConfig"]=>
- array(7) {
- ["scheme"]=>
- string(4) "http"
- ["query"]=>
- NULL
- ["fragment"]=>
- NULL
- ["protocol"]=>
- NULL
- ["auth"]=>
- NULL
- ["version"]=>
- string(3) "1.1"
- ["headers"]=>
- array(0) {
- }
- }
- }
- // expected
- array(1) {
- ["fu::__defaultConfig"]=>
- array(7) {
- ["scheme"]=>
- string(4) "http"
- ["query"]=>
- NULL
- ["fragment"]=>
- NULL
- ["protocol"]=>
- NULL
- ["auth"]=>
- NULL
- ["version"]=>
- string(3) "1.1"
- ["headers"]=>
- array(0) {
- }
- }
- }
- array(1) {
- ["baz::__defaultConfig"]=>
- array(7) {
- ["scheme"]=>
- string(4) "tcp"
- ["host"]=>
- string(9) "localhost"
- ["port"]=>
- NULL
- ["username"]=>
- NULL
- ["password"]=>
- NULL
- ["path"]=>
- NULL
- ["body"]=>
- array(0) {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement