Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:57021 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 48347 invoked from network); 22 Dec 2011 19:23:03 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Dec 2011 19:23:03 -0000 Authentication-Results: pb1.pair.com header.from=will.fitch@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=will.fitch@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.42 as permitted sender) X-PHP-List-Original-Sender: will.fitch@gmail.com X-Host-Fingerprint: 209.85.216.42 mail-qw0-f42.google.com Received: from [209.85.216.42] ([209.85.216.42:41213] helo=mail-qw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F7/2E-12618-69383FE4 for ; Thu, 22 Dec 2011 14:23:03 -0500 Received: by qabj40 with SMTP id j40so4892308qab.8 for ; Thu, 22 Dec 2011 11:23:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=subject:mime-version:content-type:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to:x-mailer; bh=KCPTGwQMPw3tPolgrxfEC0pSHpAcO2RDM57pvB9oexE=; b=RVqGCXbM8a/YMKKDEqdzZM7EH2TTZyAuEKWiNpPOH4aBppEE+nJkrVaNM89ZiIzmSy +ySsFuHVLWn8HLraWAkwasgS30ODcwx6nmLqeb5kGRGbSaFOnWfgQuKULVqoNHwQdXBm AFwpo7pQEk4Z8euSOs6dHnEtCG3q0xeXF9WNQ= Received: by 10.224.210.130 with SMTP id gk2mr15241281qab.23.1324581780256; Thu, 22 Dec 2011 11:23:00 -0800 (PST) Received: from [192.168.1.68] ([68.64.144.221]) by mx.google.com with ESMTPS id ft9sm18987776qab.20.2011.12.22.11.22.58 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 22 Dec 2011 11:22:59 -0800 (PST) Mime-Version: 1.0 (Apple Message framework v1251.1) Content-Type: text/plain; charset=iso-8859-1 In-Reply-To: <4EF37C29.1010206@php.net> Date: Thu, 22 Dec 2011 14:22:57 -0500 Cc: internals@lists.php.net Content-Transfer-Encoding: quoted-printable Message-ID: <9FA7F250-468A-47E7-B2B4-977C5B658B4F@gmail.com> 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> <4EF37C29.1010206@php.net> To: Sebastian Bergmann X-Mailer: Apple Mail (2.1251.1) Subject: Re: [PHP-DEV] Return Type Hinting for Methods RFC From: will.fitch@gmail.com (Will Fitch) On Dec 22, 2011, at 1:51 PM, Sebastian Bergmann wrote: > 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. >=20 > Putting such code into the "correct" place does not change the problem > that you and Stas describe >=20 > function age_check($age) > { > if (!is_int($age)) { > throw new InvalidArgumentException; > } > } >=20 > 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 ... There are cases, such as the one you pointed out, that requires type = casting. We're just trying to point out a situation where, if scalars = were allowed to be typed, would produce code littered with type casts. = Point taken though. >=20 > I am not advocating type hints for scalars, I am just saying that this > argument is not really a good one against it. >=20 > --=20 > Sebastian Bergmann Co-Founder and Principal = Consultant > http://sebastian-bergmann.de/ = http://thePHP.cc/ >=20 > --=20 > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >=20