Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:80558 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 1156 invoked from network); 15 Jan 2015 15:58:12 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Jan 2015 15:58:12 -0000 Authentication-Results: pb1.pair.com header.from=j.boggiano@seld.be; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=j.boggiano@seld.be; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain seld.be designates 74.125.82.48 as permitted sender) X-PHP-List-Original-Sender: j.boggiano@seld.be X-Host-Fingerprint: 74.125.82.48 mail-wg0-f48.google.com Received: from [74.125.82.48] ([74.125.82.48:62717] helo=mail-wg0-f48.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 42/BE-14306-74ED7B45 for ; Thu, 15 Jan 2015 10:35:35 -0500 Received: by mail-wg0-f48.google.com with SMTP id l2so15618966wgh.7 for ; Thu, 15 Jan 2015 07:35:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type :content-transfer-encoding; bh=jUM/i5KFObBDvtm3FcCNDnZUAxBObImosD1kbQmXT2U=; b=FScbm5MPAjjx60LiUX32jDrYpbG7vdf69iqYJiDh5fBKwkKuhgmYJ+MJ+HGtGOspQc nVt+yXcXUnXqW1YzhSQm7+OC9oyldwiflLPL3M2pjGK64yWdJALsuhySZYiaSxX5E0PO H6sjDNyv79zSHzgEoN6VmuIkDGtzH4hY41M5kwalyZ2cqmL5tKzcLwKcaWluPhxQOdjP imGf1J64f1fS+rDwqcoECdquX+sMmBmmMJcgqhZAvy/9YRPN+JcDllaEP//m3eej8L7f RR9c7ZwyoF7o6IdSHEdQ9Uc0RNgofJPxfiXeB11xlD8iR/YKeZpAIrhkX1+JvmZN6pgY pczg== X-Gm-Message-State: ALoCoQkYgrNiBd3zx0KpPbM2HEpmp1kigR2sYRNahvdzLQUmkAOnmpW5wq+aGbeZxbXNDxY35BKd X-Received: by 10.194.80.193 with SMTP id t1mr19463607wjx.8.1421336132172; Thu, 15 Jan 2015 07:35:32 -0800 (PST) Received: from [192.168.1.66] (83.90.199.146.dyn.plus.net. [146.199.90.83]) by mx.google.com with ESMTPSA id lg7sm7942730wic.0.2015.01.15.07.35.30 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Jan 2015 07:35:31 -0800 (PST) Message-ID: <54B7DE53.4070806@seld.be> Date: Thu, 15 Jan 2015 15:35:47 +0000 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: =?UTF-8?B?UGF2ZWwgS291xZlpbA==?= CC: PHP internals References: <8DCD1B72-C81D-499E-B455-E4A042CD76E6@ajf.me> <4E2073DE-0951-498C-97BB-DDAC094F11FA@ajf.me> <9a033dd1f223f854e760924d118ab812@mail.gmail.com> <2ae0164cb9b9bf1c974d7a3c60af0466@mail.gmail.com> <6105ea99002e634373c09685310e26a6@mail.gmail.com> <85F6139E-6332-4645-91B8-C852B07EA62A@ajf.me> <54B7DA71.1050905@seld.be> In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] [RFC] Scalar Type Hints v0.2 From: j.boggiano@seld.be (Jordi Boggiano) On 15/01/2015 15:31, Pavel KouĊ™il wrote: > On Thu, Jan 15, 2015 at 4:19 PM, Jordi Boggiano wrote: >> >> Right now, or with only weak hints, if a library decides to implement strict >> typing, they'll skip the scalar hints and check types with something like >> the assert lib [1]. A user calling it with random data would *always* get >> exceptions. There is no way for the library to use scalar hints to play nice >> with weak-typed callers as it would not be able to type check anymore in >> that case. >> > > Why would the libraries writers use the checks inside the method > instead of the typing, even in the case of the weak typing? I don't > see a single reason to do so, because if they ask for an "int" in the > method signature, they will get an int or the method won't get called > at all. See the example in the RFC with the "if (!is_int($i))". I mean that if someone wants strict typing they won't want to use weak hints because that would coerce the data before they can verify it and ensure their code is strictly typed. Therefore the best course of action is to have no hint + check manually, like they are doing now with such libs. Cheers -- Jordi Boggiano @seldaek - http://nelm.io/jordi