Re: Return Type Hinting for Methods RFC
| From: | Oleg Oshmyan | Date: | Thu, 22 Dec 2011 15:18:14 +0000 |
| Subject: | Re: Return Type Hinting for Methods RFC | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-57004@lists.php.net to get a copy of this message | ||
> public function \Customer getCustomer(){
> return $this->customer;
> }
>
> If the $customer instance variable is not declared with the type Customer
> then first of all IDE will not be able to spot an error, second compiler may
> have a slighly harder time of detecting a mismatch.
The compiler does not even try to detect a mismatch; type hinting is
taken into account at run-time only. So whenever this function executes,
if it tries to return a value that is not a \Customer, a run-time error
will be reported.
--
Oleg