Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:98906 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 37250 invoked from network); 29 Apr 2017 15:53:48 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 Apr 2017 15:53:48 -0000 Authentication-Results: pb1.pair.com smtp.mail=php@golemon.com; spf=softfail; sender-id=softfail Authentication-Results: pb1.pair.com header.from=php@golemon.com; sender-id=softfail Received-SPF: softfail (pb1.pair.com: domain golemon.com does not designate 209.85.128.176 as permitted sender) X-PHP-List-Original-Sender: php@golemon.com X-Host-Fingerprint: 209.85.128.176 mail-wr0-f176.google.com Received: from [209.85.128.176] ([209.85.128.176:36047] helo=mail-wr0-f176.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 79/F5-01540-A07B4095 for ; Sat, 29 Apr 2017 11:53:47 -0400 Received: by mail-wr0-f176.google.com with SMTP id l50so46682001wrc.3 for ; Sat, 29 Apr 2017 08:53:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=golemon-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=xdU2GoIs9EPHkfbAhsADFhoBo5Oyb6CT5qHR60y7/Vc=; b=dd/yE1opNL2cLCqpTESPBmh7MiEcuPzEOYou2lsre/je38ouI4mzdpf1oc7l1/40KO 4eTgYwbp2N2J9c4QxPY0FNEzx+XX7//gmYTx7JlbY9p9n4/sepoySbczwlID5t86dbYy 840WB/CFrWI7hpCjKkXh6jBLzIW6pL5yAp4gvsCESTysWU/ifewa2PEAzU+z0Ge25kVb Hwk/Ibx82N69lIzPuGAqGfUwe1WjQ4l2dGcudso5q1ikxWsz2F5GGr2L9N9Mx8J291kJ 1GkOCcrixhv2x07a0QwSxzSNDNc578bDKGFNT0cTyn4gokRMED3X5xfviXRQeWkhZ22b VMXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=xdU2GoIs9EPHkfbAhsADFhoBo5Oyb6CT5qHR60y7/Vc=; b=YRL+pbRlXMUc1fqpEtEsH4ix2Do0M7g2TTlrIclYd+Hr25bQVcQ3W//FaM4kVmmjZ5 /fVNylXnkrqmQzjQRRehe6M9r9SYNDrWGyOkNtLLe0fsDoM+Y4XngJWGouyJbSL817pO 0Hmvky/a1MnJ4MZ0Hroy3KyW4NZRc+7kK5CbMY+ptsfVvof4mtRvlY8WTvlaXlkiuf79 2cCl52q8NDkmWgBvDPrSWVQyZTy4YFRDXN3tdg8jE0gJrFC6HiJAVp0mWqBKe3gLbrDG dqDgEEOABdPEzOUTTXwsEh2OoFGV8kYsGLZQYN0orHvlJ23OhZ+6miuiLEFCNTPcPsLf rpvg== X-Gm-Message-State: AN3rC/5bZf2KWzWA5SQHsC0P+6yyDYPAG954b4bxRXEkjDx2ttv6Z3lZ iNRxITwe/ZebiGs54hVf3s/MLkqJOA== X-Received: by 10.223.173.74 with SMTP id p68mr10616470wrc.163.1493481224121; Sat, 29 Apr 2017 08:53:44 -0700 (PDT) MIME-Version: 1.0 Sender: php@golemon.com Received: by 10.223.157.38 with HTTP; Sat, 29 Apr 2017 08:53:43 -0700 (PDT) X-Originating-IP: [73.9.224.155] In-Reply-To: <8F7D0233-DB1A-4617-8E92-C1719D4D385D@gmail.com> References: <398456D8-170A-4629-B6FF-D64F6DDB9C9A@gmail.com> <5B258485-B7EE-4DCD-B93F-B036E9B6D4CC@gmail.com> <8F7D0233-DB1A-4617-8E92-C1719D4D385D@gmail.com> Date: Sat, 29 Apr 2017 10:53:43 -0500 X-Google-Sender-Auth: taj4SoGyUTm1SGIc7Vz0lb800QE Message-ID: To: Rowan Collins Cc: PHP internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] [RFC] Enable strict_types checking for curl_setopt() From: pollita@php.net (Sara Golemon) On Sat, Apr 29, 2017 at 10:01 AM, Rowan Collins wrote: > That mix sounds very reasonable. Does it still make you go "eww" to suggest > that those settings that don't deserve their own method, and take a boolean > argument rather than a string or int, could have a different method, such as > setFlag? Because that's really all I was suggesting: a more visible > distinction that said "this method always takes a boolean", rather than > "this method must be given a boolean if given this, that, or the other". > It certainly seems unnecessary. setBool(), setInt(), setOffset(), setString(), versus setOption() is imposing a design detail on the consumer that shouldn't be relevant to them. In fact, in weak mode, it becomes especially irrelevant to know the difference between an int and a bool setting. Specifying type in the method name is essentially imposing a cognitive form of strict mode on those who don't want it. > Meanwhile, I'll repeat that if there really is precedent for functions > validating their arguments based on both strict_types mode and the value of > some other parameter, then my concern (mostly) evaporates, and I suspect > others' might also. I just checked through the thread and RFC, and can't see > these examples being named, so I would very much appreciate a specific > example. > Not on *both* strict mode and the value of another parameter, there's very little application of strict mode throughout the codebase because strict mode is new. What there are precedents of, and what I was responding to in your earlier email, was the idea that an arguments type can vary based on the type and/or number of other arguments. This precedent exists in the pg_*() methods as I already pointed you at, and a quick grep shows stream_context_set_option(), and a particularly fascinating "signature" in intlcal_set(). > Perhaps the precedents seem obvious to you, and that's why this whole > conversation is frustrating you? It definitely feels like there is some > miscommunication, because you seem surprised that people have any concerns > at all. > I'm not surprised that there are concerns, I'm just shocked that the concerns are so poorly founded. Arguments I've heard so far fall into two categories. 1. If the parameter isn't reflectable, then it shouldn't be subject to enforcement. This argument holds no water because internal functions can only reflect array or object type hints, yet we enforce other types routinely. 2. Type enforcement should not depend on the declare(strict_types=1); directive. This argument is ridiculous on the face of it, since that's precisely what that declare() directive was designed for. The fact that the type being enforced is dependent on another arg's value is an irrelevant implementation detail. Think about the user's experience here. Bob wants to call curl_setopt($ch, CURLOPT_RETURNTRANSFER, $value); Bob expects $value to be validated and used as a boolean. If Bob has strict_types set, he expects an exception if $value isn't a bool, if it's not set, he expects the value to be quietly converted (if possible within type affinity). -Sara