-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In line with usual rules, give untyped properties a null default value. Otherwise constructor promotion would give you a property declaration that cannot be achieved through any other means.
- Loading branch information
Showing
3 changed files
with
40 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--TEST-- | ||
Bug #79867: Promoted untyped properties should get null default value | ||
--FILE-- | ||
<?php | ||
|
||
class A { | ||
public function __construct( | ||
public $untyped = 1, | ||
public int $typed = 2, | ||
) {} | ||
} | ||
|
||
class B extends A { | ||
public function __construct() { | ||
// Missing parent::__construct() call, | ||
// properties will not be initialized. | ||
} | ||
} | ||
|
||
var_dump(new B); | ||
|
||
?> | ||
--EXPECT-- | ||
object(B)#1 (1) { | ||
["untyped"]=> | ||
NULL | ||
["typed"]=> | ||
uninitialized(int) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters