PHP Scalar Type Hints

php-logo

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:

A pity imho.

PHP RFC: Scalar Type Hints →
PHP RFC: Return Type Declarations →

Published by Bramus!

Bramus is a frontend web developer from Belgium, working as a Chrome Developer Relations Engineer at Google. From the moment he discovered view-source at the age of 14 (way back in 1997), he fell in love with the web and has been tinkering with it ever since (more …)

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.