php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77673 ReflectionClass#getDefaultProperties() produces empty array with existing keys
Submitted: 2019-02-26 23:45 UTC Modified: -
From: ocramius@php.net Assigned:
Status: Closed Package: Reflection related
PHP Version: Next Minor Version OS: Irrelevant
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: ocramius@php.net
New email:
PHP Version: OS:

 

 [2019-02-26 23:45 UTC] ocramius@php.net
Description:
------------
ReflectionClass#getDefaultProperties() produces an array with an invisible property when used in combination with typed properties

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

class A {
    public B $c;
}

$class = new ReflectionClass(A::class);

$defaults = $class->getDefaultProperties();

var_dump($defaults);
var_dump(array_key_exists('c', $defaults));

Expected result:
----------------
array(0) {
}
bool(false)

Actual result:
--------------
array(1) {
}
bool(true)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-02-27 08:18 UTC] krakjoe@php.net
Automatic comment on behalf of krakjoe
Revision: http://git.php.net/?p=php-src.git;a=commit;h=1ca9d818b8405159ef96cb974a21714881e1146c
Log: Fix #77673 ReflectionClass::getDefaultProperties returns spooky array
 [2019-02-27 08:18 UTC] krakjoe@php.net
-Status: Open +Status: Closed
 [2019-02-27 08:18 UTC] krakjoe@php.net
Automatic comment on behalf of krakjoe
Revision: http://git.php.net/?p=php-src.git;a=commit;h=1ca9d818b8405159ef96cb974a21714881e1146c
Log: Fix #77673 ReflectionClass::getDefaultProperties returns spooky array
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 01 17:01:34 2025 UTC