Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:75400 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 38811 invoked from network); 13 Jul 2014 14:22:04 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Jul 2014 14:22:04 -0000 Authentication-Results: pb1.pair.com smtp.mail=zeev@zend.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=zeev@zend.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 209.85.220.171 as permitted sender) X-PHP-List-Original-Sender: zeev@zend.com X-Host-Fingerprint: 209.85.220.171 mail-vc0-f171.google.com Received: from [209.85.220.171] ([209.85.220.171:39196] helo=mail-vc0-f171.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 11/F3-16748-B0692C35 for ; Sun, 13 Jul 2014 10:22:03 -0400 Received: by mail-vc0-f171.google.com with SMTP id id10so5381708vcb.2 for ; Sun, 13 Jul 2014 07:22:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:references:in-reply-to:mime-version :thread-index:date:message-id:subject:to:content-type; bh=EXR7MwH6Wgb+AAly8A+iOgI4vAUJCloYAvcHtGFvT4Q=; b=IJGthVe/KoClgi6g86gezEpUU31y1GbCCihphBJGU7w0xb5LlgLpHr9+5IUr6+jG+5 6I/FM7K71l1JyUnG+xP55qNn2oeNBj3ic/XXavAFj4kOTVg5uvRFLMXy9FOx3kO9KFoZ 3NpOPrrr2t08ke3IwWlg2e/Tirg2hprscqwEk8PKcF52CGN7BUCn5ZvL5FzuVKBCm9Se t3F3t4jPszw2e7Vb1M8DfoHjt9eoVQN62IeTz5Q/aEYNY+yzF1uSKIQnHTISAW2HETQJ izNHhB60NjBYp7bVhYfih+ZtShBrBcsquNuV4lSy7+eYCRdAqnMm2uQsxIx5dClK8fT6 /s4w== X-Gm-Message-State: ALoCoQlUam8Lf2++ILCHThhCeTl77o3hW+azqEXi54O4sq2bjxUrvCqUAFVeJc47yF8yvsC1mwbYtzflkBjJDsguVGXNdpSo6dgpzG3JpzWAjsOXFt22S+uIQOabFBkzRxN5tcnE1aKL X-Received: by 10.221.4.66 with SMTP id ob2mr279960vcb.28.1405261320259; Sun, 13 Jul 2014 07:22:00 -0700 (PDT) References: <08503591-EFC8-48E6-984E-FFC292C5EA5F@ajf.me> <53C2178E.7070705@sugarcrm.com> <53C24061.6050503@lsces.co.uk> <20140713101840.GR6540@phcomp.co.uk> <2f218b4d8cffb1a55e464e715c319b1f@mail.gmail.com> <20140713132042.GU6540@phcomp.co.uk> In-Reply-To: <20140713132042.GU6540@phcomp.co.uk> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQJuUFVOlGiX172RfpkkW7aXwqSXwwKNH6ZhAjN2Q/kB5EycswM8VxKBAkcM9KWZ/2eNsA== Date: Sun, 13 Jul 2014 17:21:59 +0300 Message-ID: <3061bf696f53463cf4063ec11f71f775@mail.gmail.com> To: Alain Williams , internals@lists.php.net Content-Type: text/plain; charset=UTF-8 Subject: RE: [PHP-DEV] [RFC] Scalar Type Hinting With Casts (re-opening) From: zeev@zend.com (Zeev Suraski) > Which of the two below is clearer: > > function CanDrive($age) > { > if( !is_numeric($age)) > throw new Error("\$age is not integer (CanDrive())"); > > return $age >= 17; > } > > function CanDrive(int $age) > { > return $age >= 17; > } I think we're on the same page here that the 2nd one looks better, which is the point of the RFC. But the way I see it, the RFC should focus pretty much exclusively on sanitizing information coming from the 'outer code' and into the 'inner code', as opposed to enforcing strict typing within the inner code (a function that unless I'm missing something it does not attempt to do, thankfully). The point of the RFC is that as the author of the API, you wouldn't have to worry about input sanity, while still allowing the dynamic nature of PHP - AKA type juggling - so that users who call that API don't need to be bothered with the mechanics of their types either. Zeev