Bug #78319 [Opn]: get_class_vars/ReflectionClass::getDefaultProperties don't show typed propertie

From: Date: Mon, 22 Jul 2019 15:07:47 +0000
Subject: Bug #78319 [Opn]: get_class_vars/ReflectionClass::getDefaultProperties don't show typed propertie
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-221893@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=78319&edit=1 ID: 78319 Updated by: nikic@php.net Reported by: nicolas dot grekas+php at gmail dot com Summary: get_class_vars/ReflectionClass::getDefaultProperties don't show typed propertie Status: Open Type: Bug Package: Reflection related PHP Version: 7.4.0alpha3 Block user comment: N Private report: N New Comment: Not sure about this one. I can see how not returning them can be a problem, but just returning null also seems wrong, because it's not the actual default value. Previous Comments: ------------------------------------------------------------------------ [2019-07-22 07:53:07] nicolas dot grekas+php at gmail dot com Description: ------------ get_class_vars()/ReflectionClass::getDefaultProperties() don't show typed properties. I get they aren't yet initialized, but we could report them as "null" to no break scripts that look only for their names. Test script: --------------- class Php74 { public $p1 = 123; public \stdClass $p2; public function __construct() { $this->p2 = new \stdClass(); } } print_r(get_class_vars('Php74')); $r = new \ReflectionClass('Php74'); print_r($r->getDefaultProperties()); print_r($r->getProperties()); Expected result: ---------------- Array ( [p1] => 123 [p2] => ) Array ( [p1] => 123 [p2] => ) Array ( [0] => ReflectionProperty Object ( [name] => p1 [class] => Php74 ) [1] => ReflectionProperty Object ( [name] => p2 [class] => Php74 ) ) Actual result: -------------- Array ( [p1] => 123 ) Array ( [p1] => 123 ) Array ( [0] => ReflectionProperty Object ( [name] => p1 [class] => Php74 ) [1] => ReflectionProperty Object ( [name] => p2 [class] => Php74 ) ) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=78319&edit=1

« previous php.bugs (#221893) next »