php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78901 wrong output of var_dump() for uninitialized typed properties with xdebug
Submitted: 2019-12-03 13:36 UTC Modified: 2020-01-20 18:17 UTC
Votes:1
Avg. Score:2.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: public at grik dot net Assigned: derick (profile)
Status: Closed Package: Xdebug
PHP Version: 7.4.0 OS:
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: public at grik dot net
New email:
PHP Version: OS:

 

 [2019-12-03 13:36 UTC] public at grik dot net
Description:
------------
var_dump() does not show named properties that were not initialized, 
it just shows that _something_ is there

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

class A{
    public string $x;
}

var_dump(property_exists($A,'x'));//true
var_dump($A); //class A#1 (1) {} // - it counts the property, but hides it
var_dump(new stdClass()); //class stdClass#1 (0) {} - empty object

Expected result:
----------------
class A#1 (1) {
  public $x =>
  NULL
}

Actual result:
--------------
class A#1 (1) {
} 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-12-03 14:15 UTC] cmb@php.net
-Summary: wrong output of var_dump() for uninitialized named properties +Summary: wrong output of var_dump() for uninitialized typed properties
 [2019-12-03 14:15 UTC] cmb@php.net
Works as expected on <https://3v4l.org/gvDf5>.
 [2019-12-03 17:28 UTC] requinix@php.net
-Status: Open +Status: Feedback
 [2019-12-03 19:24 UTC] public at grik dot net
-Summary: wrong output of var_dump() for uninitialized typed properties +Summary: wrong output of var_dump() for uninitialized typed properties with xdebug -Status: Feedback +Status: Open -Package: *General Issues +Package: Xdebug
 [2019-12-03 19:24 UTC] public at grik dot net
It is reproduced with xdebug enabled.
 [2019-12-03 19:35 UTC] public at grik dot net
with xdebug disabled it works fine

PS C:\> php -r 'var_dump(new class{public string $x;});'
object(class@anonymous)#1 (0) {
  ["x"]=>
  uninitialized(string)
}

enable xdebug 2.8.1

PS C:\> php -r 'var_dump(new class{public string $x;});' -d "zend_extension=xdebug"
Command line code:1:
class class@anonymous#1 (1) {
}

thanks and sorry for confusion
 [2019-12-03 21:58 UTC] derick@php.net
Please report Xdebug bugs at https://bugs.xdebug.org
 [2020-01-20 17:11 UTC] derick@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: derick
 [2020-01-20 17:11 UTC] derick@php.net
This was fixed in Xdebug 2.9.0 -> https://bugs.xdebug.org/view.php?id=1724
 [2020-01-20 18:17 UTC] public at grik dot net
Thank you, Derick!
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 21:01:29 2024 UTC