Re: [RFC] Scalar Type Hints v0.2

From: Date: Thu, 15 Jan 2015 22:09:54 +0000
Subject: Re: [RFC] Scalar Type Hints v0.2
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16  Groups: php.internals 
Request: Send a blank email to internals+get-80598@lists.php.net to get a copy of this message
On 15 January 2015 20:16:54 GMT, Thomas Bley <mails@thomasbley.de> wrote: >What about doing both weak and strict with two different syntaxes? > >public function __construct(string $name, $age as int, $cuteness as >float, bool $evil) { > >string $name // strict >$age as int // weak >$cuteness as float // weak >bool $evil // strict > >"as" Syntax is taken from SQL92. > >Regards >Thomas This is what some are proposing, but with slightly different syntax choices, inspired by existing cast operators: public function __construct(string $name, (int) $age, (float) $cuteness, bool $evil) Like literally every proposal in this area, some people think it's The Solution, others absolutely hate it. Andrea has stated (if I'm not paraphrasing too badly) that a major reason for putting the caller in control, not the definer, is that it's easier to reason about code where all the calls you are looking at follow one behaviour, regardless of where they were defined.

« previous php.internals (#80598) next »