3 ms·
(I work on Hack at FB) function f(int $x): float { ... } For property and constant declarations, we chose to be consistent with the parameter typehint synta
by elgenie 13y ago
(I work on Hack at FB)
function f(int $x): float { ... }
For property and constant declarations, we chose to be consistent with the parameter typehint syntax (int $x) instead of the function return type annotation (float).
A nice effect of this decision is that this allows us to change:
class C {
private int $x = 20;
public function __construct(int $x,) {
$this->x = $x;
}
}
into the shorter and cleaner:
class C {
public function __construct(
private int $x = 20,
) {}
}