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 Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
50 - 1 = ?
Subscribe to this entry?

 
 [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

Add a Patch

Pull Requests

Add a Pull Request

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: Sun Apr 28 15:01:31 2024 UTC