Re: Return Type Hinting for Methods RFC

From: Date: Thu, 22 Dec 2011 23:21:18 +0000
Subject: Re: Return Type Hinting for Methods RFC
References: 1 2 3 4 5 6 7  Groups: php.internals 
Request: Send a blank email to internals+get-57039@lists.php.net to get a copy of this message
On Thu, Dec 22, 2011 at 06:08:26PM -0500, Will Fitch wrote: > Most modern languages allow returning null in any case. This is a hail > Mary in the event something happens, but throwing an exception is > inappropriate. I see no reason to diverge from that. Agreed, it is often convenient to return NULL or FALSE to indicate failure or something like end of input (think: fgetc()). I was mulling syntax like: function (string|boolean:false) fgetc(resource $handle) Then the compiler would know that after: if( ($ch = fgetc($in)) === FALSE) return; that $ch is string ... but seems too complicated. -- Alain Williams Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer. +44 (0) 787 668 0256 http://www.phcomp.co.uk/ Parliament Hill Computers Ltd. Registration Information: http://www.phcomp.co.uk/contact.php #include <std_disclaimer.h>

« previous php.internals (#57039) next »