Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:80557 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 1077 invoked from network); 15 Jan 2015 15:58:09 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Jan 2015 15:58:09 -0000 Authentication-Results: pb1.pair.com smtp.mail=pajousek@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=pajousek@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.47 as permitted sender) X-PHP-List-Original-Sender: pajousek@gmail.com X-Host-Fingerprint: 209.85.216.47 mail-qa0-f47.google.com Received: from [209.85.216.47] ([209.85.216.47:38237] helo=mail-qa0-f47.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 80/BE-14306-C6DD7B45 for ; Thu, 15 Jan 2015 10:31:58 -0500 Received: by mail-qa0-f47.google.com with SMTP id n8so11540020qaq.6 for ; Thu, 15 Jan 2015 07:31:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=8YGAt44YLd3YFn3HK5yAKtdw9fUYjpq4+GCZczu4f1E=; b=bnuYaUbhMK5kPgoBhxFBB+fjrmNU4xSNzStH55M3tvRPERIzzymUoJkqxr2IijXsKt m7duQbaiDhKcvkBkurh12PKX3O/28gxkezsrAf25JRFHlusuVexeoBVJou2FkRXtMCR0 /xYY9CG19+N4Ro7Y5RHJmOwBALsz3TGGqh6/pdvDoRqIctZdkeklRVN41KEBsdpgZjGc yr1ljdShxRW1Ad5KLu5F8Rgao7hPxFfDoqTbhszgHRH83E32pdyTAy7WxeRH92AdzpOm S+RGqFJmrp6y83OQ0TfJYdBqJtXFdTGTD8pjy6iQqKTldJlI/arEfIp42Xo+KoJkPww0 1jDw== MIME-Version: 1.0 X-Received: by 10.140.23.210 with SMTP id 76mr15972700qgp.84.1421335914283; Thu, 15 Jan 2015 07:31:54 -0800 (PST) Received: by 10.96.55.138 with HTTP; Thu, 15 Jan 2015 07:31:54 -0800 (PST) In-Reply-To: <54B7DA71.1050905@seld.be> 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> Date: Thu, 15 Jan 2015 16:31:54 +0100 Message-ID: To: Jordi Boggiano Cc: PHP internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] [RFC] Scalar Type Hints v0.2 From: pajousek@gmail.com (=?UTF-8?Q?Pavel_Kou=C5=99il?=) 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))". Pavel Kouril