Last active
December 4, 2019 17:44
-
-
Save krmgns/c69cd1d1136993a77d92d4f3bdd40c60 to your computer and use it in GitHub Desktop.
Another "uninitialized" thing..
This file contains hidden or 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
$foo = new class() { | |
var ?array $a; | |
function dump() { var_dump($this->a); } | |
function sort() { ksort($this->a); } | |
}; | |
// E1: Error: Typed property class@anonymous::$a must not be accessed before initialization | |
$foo->dump(); | |
// E2: TypeError: ksort() expects parameter 1 to be array, null given (should throw E1 cos its an uninitialized property?) | |
$foo->sort(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment