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
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 31 23:01:28 2024 UTC