Bug #78901 [Opn->Fbk]: wrong output of var_dump() for uninitialized typed properties

From: Date: Tue, 03 Dec 2019 17:28:43 +0000
Subject: Bug #78901 [Opn->Fbk]: wrong output of var_dump() for uninitialized typed properties
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-224024@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=78901&edit=1

 ID:                 78901
 Updated by:         requinix@php.net
 Reported by:        public at grik dot net
 Summary:            wrong output of var_dump() for uninitialized typed
                     properties
-Status:             Open
+Status:             Feedback
 Type:               Bug
 Package:            *General Issues
 PHP Version:        7.4.0
 Block user comment: N
 Private report:     N



Previous Comments:
------------------------------------------------------------------------
[2019-12-03 14:15:31] cmb@php.net

Works as expected on <https://3v4l.org/gvDf5>.

------------------------------------------------------------------------
[2019-12-03 13:36:38] 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) {
} 


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=78901&edit=1


Thread (3 messages)

« previous php.bugs (#224024) next »