Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:106640 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 31368 invoked from network); 18 Aug 2019 12:29:58 -0000 Received: from unknown (HELO mail-io1-f41.google.com) (209.85.166.41) by pb1.pair.com with SMTP; 18 Aug 2019 12:29:58 -0000 Received: by mail-io1-f41.google.com with SMTP id t3so14783949ioj.12 for ; Sun, 18 Aug 2019 02:59:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=8ieWOpqxQSXnbUpuMvG9gD9gKLXDs16E8pe5dUmWkfY=; b=bccHTRjXFid8DU/vhIZ6LhtZNmMgYj28mYdWmeHzrdsDgPFEgE8/kifzCoH4hJbh/I X4QSyWl5r7H5b4veLBQrX9yJZKFGfDwW3a6mD34/Z+YAlkXtVcHFQz8MZJAqPjh2IDKF AwCSqVpl3Az4h8TqfYlYizJdPq6pbUltJQiANwFFg9RhcQ5/4fooXA6lgEzxgk9AXf+K +ymgCfoSm8F4zIe1ZNM3VWDNNnAWYTg3r+PJ09S6fWjp4K/i15kHNIShoyLKnUI96KHK tbZrn12G/lDmGU7NbpU3rU95RWQkHWVMRmIHEEFYQIcyehKgOot04biyqKlho0Q/nCLp 9HPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=8ieWOpqxQSXnbUpuMvG9gD9gKLXDs16E8pe5dUmWkfY=; b=VbwY6HVwFffY8Wk9/DArEf1FV3Jd5310NxpuBfquVCmMlYYve0wXORSBIKeYTVbseG hh/sV4/o4LsvQ6QKH1zi20aQMkmUJThqEETWteZRrshCRporBD0x5rAEME2cLt8aOd68 RFqg93oxANINJ7qAS+cjNDhIKt5zy7ttslwR02397RX59/MGlGIMwNoPIns/QNASAMp7 hn5qfp5CFqaiq+sGB2D5fbLiaVoTugkMXSdRZr5cG2pco217C81DEux98Qw4JJnMlktb rDWzWeq6ZtrGjKQ/PS3UJLa5XNv8+ekvGWlLsWwtWnMHIxapVwG5s7FrXvOs5ma9Vgeb RVOA== X-Gm-Message-State: APjAAAWirWECuU26sv70v5PFDFn+LoNM3Y3usNK5Zddvsl4TkmfHZMIL 5ULaZAoYGDcgei4uNZCqdet87tPwrt7/ujMfOoS73QHQJ+M= X-Google-Smtp-Source: APXvYqzR7cCDGnlSlQhTPiJRD7QsGa/LvxWvhDWdcZmyNjgxrxzXUhJA/9J+4KaGUCyPiAxfDWefxZ0zB/2s2HsSgf4= X-Received: by 2002:a02:9644:: with SMTP id c62mr20534432jai.45.1566122374553; Sun, 18 Aug 2019 02:59:34 -0700 (PDT) MIME-Version: 1.0 Date: Sun, 18 Aug 2019 11:59:20 +0200 Message-ID: To: PHP Internals Content-Type: multipart/alternative; boundary="000000000000cf670a0590614766" Subject: get_class_vars() and typed properties From: benjamin.morel@gmail.com (Benjamin Morel) --000000000000cf670a0590614766 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Internals, I just noticed the following behaviour: class A { public int $a; public ?int $b; public ?int $c =3D null; } $a =3D new A; var_export(get_object_vars($a)); var_export(get_class_vars('A')); Result: array ( 'c' =3D> NULL, ) array ( 'a' =3D> NULL, 'b' =3D> NULL, 'c' =3D> NULL, ) Is this discrepancy expected? IMO get_object_vars() does the right thing and does not include uninitialized properties in the result array. OTOH, get_class_vars() returns null when the property is uninitialized, which I think is confusing (especially when null is not a valid value for the property), and I feel like this does not respect the documented contract: "get_class_vars =E2=80=94 Get the default properties of the class= " when null is *not* the default value. I did not file a bug yet as I wanted to gather some feedback first. Thank you. =E2=80=94 Benjamin --000000000000cf670a0590614766--