Re: AW: [PHP-DEV] Renaming type-hints to something else?
| From: | Rowan Collins | Date: | Wed, 17 Sep 2014 16:01:27 +0000 |
| Subject: | Re: AW: [PHP-DEV] Renaming type-hints to something else? | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-77296@lists.php.net to get a copy of this message | ||
Robert Stoll wrote (on 16/09/2014):
I would argue "type declaration" is wrong as well since it is not a type declaration as it is known in other languages where the type declaration is binding. IMO it is more a "type check". Consider the following function foo(Bar $b){ $b = 1; //$b is not a Bar at all }I tend to think of them as "type assertions", since this: function foo(Bar $b){
// do stuff} is kind of equivalent to this: function foo($b){
assert($b instanceOf Bar);
// do stuff
}
i.e. it's a runtime-enforced check