php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78810 RW fetches do not throw "uninitialized property" exception
Submitted: 2019-11-13 19:56 UTC Modified: -
From: nikic@php.net Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 7.4.0RC5 OS:
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:
40 - 34 = ?
Subscribe to this entry?

 
 [2019-11-13 19:56 UTC] nikic@php.net
Description:
------------
Accesses to uninitialized typed properties currently only throw an exception for R fetches, but not increments (https://3v4l.org/PPkFu) or compound assignment operators (https://3v4l.org/eHkLs). These should throw as well.

Salvaged from bug #78809, which had to be deleted due to inappropriate language.

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

class Test {
    public int $i;
}
$test = new Test;
$test->i++;

Expected result:
----------------
Uncaught Error: Typed property Test::$i must not be accessed before initialization

Actual result:
--------------
Notice: Undefined property: Test::$i in /in/oqvf3 on line 7

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-11-15 11:09 UTC] nikic@php.net
Automatic comment on behalf of nikita.ppv@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=266f3a02bce4e4c68f93744540c9bfd32516c868
Log: Fixed bug #78810
 [2019-11-15 11:09 UTC] nikic@php.net
-Status: Open +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 20:01:29 2024 UTC