Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:57011 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 34401 invoked from network); 22 Dec 2011 18:51:24 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Dec 2011 18:51:24 -0000 Authentication-Results: pb1.pair.com smtp.mail=sebastian@php.net; spf=unknown; sender-id=unknown Authentication-Results: pb1.pair.com header.from=sebastian@php.net; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 93.190.64.37 as permitted sender) X-PHP-List-Original-Sender: sebastian@php.net X-Host-Fingerprint: 93.190.64.37 mail-7.de-punkt.de Received: from [93.190.64.37] ([93.190.64.37:39190] helo=mail-7.de-punkt.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 0E/EA-12618-82C73FE4 for ; Thu, 22 Dec 2011 13:51:22 -0500 Received: (qmail 19452 invoked by uid 511); 22 Dec 2011 18:51:24 -0000 Received: by simscan 1.3.1 ppid: 19446, pid: 19449, t: 0.3466s scanners: attach: 1.4.0 Received: from unknown (HELO ?192.168.2.31?) (sb@sebastian-bergmann.de@84.150.72.21) by 0 with ESMTPA; 22 Dec 2011 18:51:24 -0000 Message-ID: <4EF37C29.1010206@php.net> Date: Thu, 22 Dec 2011 19:51:21 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:9.0) Gecko/20111220 Thunderbird/9.0 MIME-Version: 1.0 To: internals@lists.php.net References: <2095305E-D4E3-4D7E-8218-32EE99688E0C@GMAIL.COM> <2C90FB94-38C4-4270-8C6A-B89304BA8ED8@gmail.com> <159A7CA2-8561-40DA-9434-CAAE12304DDB@gmail.com> <005701ccc0b3$58c8dee0$0a5a9ca0$@alliantinternet.com> <20111222145159.GY25857@alliantinternet.com> <006101ccc0ba$46b81160$d4283420$@alliantinternet.com> <4EF379D8.9000206@lerdorf.com> In-Reply-To: <4EF379D8.9000206@lerdorf.com> X-Enigmail-Version: 1.3.4 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Return Type Hinting for Methods RFC From: sebastian@php.net (Sebastian Bergmann) Am 22.12.2011 19:41, schrieb Rasmus Lerdorf: > This is not a step forward. If the author of age_check() really doesn't > want to accept type-juggled arguments, then it is easy enough to do a > strict type check in the function itself. This puts the effort in the > correct place and doesn't encourage this type of coding. Putting such code into the "correct" place does not change the problem that you and Stas describe function age_check($age) { if (!is_int($age)) { throw new InvalidArgumentException; } } With the above code, the caller needs to cast and the writer of the age_check() function has to copy/paste/adapt these checks to all the correct places ... I am not advocating type hints for scalars, I am just saying that this argument is not really a good one against it. -- Sebastian Bergmann Co-Founder and Principal Consultant http://sebastian-bergmann.de/ http://thePHP.cc/