At this moment a vote on the PHP RFC “Scalar Type Hints” is going on. It would allow stuff like this:
<?php
class ElePHPant {
public $name, $age, $cuteness, $evil;
public function __construct(string $name, int $age, float $cuteness, bool $evil) {
$this->name = $name;
$this->age = $age;
$this->cuteness = $cuteness;
$this->evil = $evil;
}
}
With the “Return Type Declarations” RFC passed, I’d find it logical to also let this vote pass. I hope they reach the 2/3 majority – which is required as the RFC proposes a change in the PHP language – by the time the vote closes (2015-02-19). With the current 2123 to 20 it looks like this feature won’t make it though.
UPDATE: This vote will not pass. As @SaraMG clarified:
@bramus Yeah, but enough have voted to predict the final outcome.
— SaraMG (@SaraMG) February 6, 2015
A pity imho.
PHP RFC: Scalar Type Hints →
PHP RFC: Return Type Declarations →