Skip to content

Instantly share code, notes, and snippets.

@krmgns
Last active December 4, 2019 17:44
Show Gist options
  • Save krmgns/c69cd1d1136993a77d92d4f3bdd40c60 to your computer and use it in GitHub Desktop.
Save krmgns/c69cd1d1136993a77d92d4f3bdd40c60 to your computer and use it in GitHub Desktop.
Another "uninitialized" thing..
$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