Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:80547 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 94380 invoked from network); 15 Jan 2015 15:19:04 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Jan 2015 15:19:04 -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.175 as permitted sender) X-PHP-List-Original-Sender: j.boggiano@seld.be X-Host-Fingerprint: 74.125.82.175 mail-we0-f175.google.com Received: from [74.125.82.175] ([74.125.82.175:60934] helo=mail-we0-f175.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A9/AD-14306-56AD7B45 for ; Thu, 15 Jan 2015 10:19:02 -0500 Received: by mail-we0-f175.google.com with SMTP id k11so15281441wes.6 for ; Thu, 15 Jan 2015 07:18:58 -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 :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=MiOjVyCzUR2TtwhYdoOknewnpjQ7QXsSa3FaLgNmVi0=; b=VbLOkrLCTOWFtyNICF0J80mPDoCDkdJwdEBPLHzHifJOyQNwGfnpBORh0fHMdLKXiZ RB0IGjxTG1EXBcBnU/6cf6yXgKWNY/mDpNDxHKV1cauzgE6a8jf/fYoY7EYeQQpQW2jZ 2b9lGXNwRJPH4lWjpMeWcLoq0m/l1GAxunI5D0R787LGDOZchPCUGzj27aDq/EabZTnc D53hZiMZ591mYOo36+jSEKMI+XpcvEbTbrWasCWCzlCrB6g0wWQ0n2Iif5fKyLOHv4D5 eYKXPY9I+QHxCj4X1yq3/RGFI/dYU5MjMde2n8TLHKFtRoFWN8wQKlosPU2ZqkGX8IIU DsGA== X-Gm-Message-State: ALoCoQkfXUQvMAmV9sYFGumQ5PeRrdEGYe7riHPgPA4j37N7hAy2l1cre3arR9uTVXrQaSnHWs9q X-Received: by 10.180.103.129 with SMTP id fw1mr5742662wib.49.1421335138644; Thu, 15 Jan 2015 07:18:58 -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 u18sm2440255wjq.42.2015.01.15.07.18.57 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Jan 2015 07:18:57 -0800 (PST) Message-ID: <54B7DA71.1050905@seld.be> Date: Thu, 15 Jan 2015 15:19:13 +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: internals@lists.php.net 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> 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:10, Zeev Suraski wrote: >> Except that is not the case for this proposal, which explicitly and >> deliberately >> prevents the directive affecting inclusion. The behaviour is impossible to >> toggle at runtime, unless you’re using some weird extension which lets you >> edit the flag on the ZEND_DO_FCALL opcode. > > Fact is that people who run websites where they don't care about strict > typing, can end up viewing strict type failures coming from code they don't > own, which would make the app fail 'catastophically' and unpredictably. > You'd have no way to turn it off (without diving to and changing the file in > question) - because it's the code itself that turns it on - and from the > user's point of view, for all practical purposes, at runtime. > > I agree that the scope of breakage of using a local file definition is much > reduced compared to an INI entry, but it's still there. I agree that's a bad situation, but if a library uses strict types via declare, it is likely that it would also use scalar hints on its own method definitions. Not doing so would be irresponsible IMO as you'd indeed expose your API's users to strict failures. If you do use strict types + scalar hints, a user passing random data from a non-strict file would never get a failure as the data would be coerced before reaching the strict library. 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. That is the value I see in the declare() proposal, although whether it's declare() or some other way to enable this per file I don't really care. [1] https://github.com/beberlei/assert -- Jordi Boggiano @seldaek - http://nelm.io/jordi