Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112232 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 94008 invoked from network); 11 Nov 2020 22:25:22 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 11 Nov 2020 22:25:22 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 342B51804C3 for ; Wed, 11 Nov 2020 13:47:52 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.2 required=5.0 tests=BAYES_40,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 11 Nov 2020 13:47:51 -0800 (PST) Received: by mail-wm1-f48.google.com with SMTP id a65so3697548wme.1 for ; Wed, 11 Nov 2020 13:47:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=bLOYOrODK4yrReUbOqJEkz700onu9RzbC1MAIbhRGG4=; b=Bx1Xt58aXJSMnQeiTdS6VSxLnBohMTCwbYAVPL6CczjYyo3iei+pq/QT7lBzJd0Bhi e8xQjZyh3hQWV3Jfr1RfrHMXIWL5bWMeFoxc64DBL/J2cMjTAFr4Qu6CtALmcXMlg3lv vnJcNOGAeH+qSLN3x8mtb7hNN9q0f+9OKt4MKr2YFetDrugOnICPm/3qwvPUE52/gTGF J0wcL6AVZxQv6JsrOMgWrHaapJ5fFtklwJWsB0afpdz9B4eQKPpiMDWPmVrs2TWFRwGk lEFR4Z0M2iOqtd1mIV/IkV09BIAaIcsJmD6GHbdv3CurHJQfERDYXT7/I98HrObMeUB4 aCMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=bLOYOrODK4yrReUbOqJEkz700onu9RzbC1MAIbhRGG4=; b=qiepy6SBn2e3awbo/816JaGYcVVKz6IAGCmfWGPwo2SHc7GP6S6t/fzIKMN41Mkd16 k2acdR59shrb6vUy6iwtFgC562gZtNVH+cj7jmBNDxwEjcNOJ0NO0etvGgBEGhcVh2j9 6JIMakxSi8+boUkKXXlppD/eIA0v7KL2GLWqD+P0vlq8jjrRBFpFwNhpBiuCrL2iNYhK NmXbv3bFLHum6G/YwrQ/IsFbZ8xeaOnd94QfdXHqsR39+jy2ESXRQ5JH+1KOdk0HX6GZ MxwFLpt/mjDXM/X0dnz+9cTtA3r9KRbpu8+vnXIMYA7j6dHuyng3+qn3COiF359faLoD lL7w== X-Gm-Message-State: AOAM530FtBq0IykYei/Y1pfvv/K+c7Dg6eZUVx1bfZdisJctGbrZWu2H b23ezbHQHwmpzFO+7NDIpPp24ohQxM4= X-Google-Smtp-Source: ABdhPJxWWskqxWvOH46pjL251J7BchenYqXNoFkZghUVdMxfOaRsuwGRlyoJUfl5fbeNt8Phl1/+Ww== X-Received: by 2002:a05:600c:2282:: with SMTP id 2mr6633075wmf.154.1605131269097; Wed, 11 Nov 2020 13:47:49 -0800 (PST) Received: from [192.168.0.22] (cpc104104-brig22-2-0-cust548.3-3.cable.virginm.net. [82.10.58.37]) by smtp.googlemail.com with ESMTPSA id t9sm3896925wrr.49.2020.11.11.13.47.48 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 11 Nov 2020 13:47:48 -0800 (PST) To: internals@lists.php.net References: Message-ID: <68aba5e0-6cfd-5946-3e01-2bccca546db7@gmail.com> Date: Wed, 11 Nov 2020 21:47:46 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.4.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB Subject: Re: [PHP-DEV] strict_types will be default at some moment? From: rowan.collins@gmail.com (Rowan Tommins) On 11/11/2020 20:20, David Rodrigues wrote: > I have been asked by a friend if declare(strict_types=1) will be applied by > default for some version of PHP, like 9.x or will it be always required by > all scripts forever. Someone can tell me? > > If yes, what is the reason for requiring it? Why it can't be the default > behavior (or maybe, the unique behavior). The question (which I hear often) misunderstands the original intent of the declaration, as I understand it: the strict_types switch was not designed as a transition mechanism for old code, it was designed as a genuine choice between two different options, both equally new. Before PHP 7.0, there was no ability for a (user-defined) function to declare that it wanted an int, string, float, or boolean argument. When it was proposed that these "scalar type hints" be added, there were different, strongly held, opinions on how that should work, leading to at least 5 separate RFCs, several thousand mailing list posts, and a lot of general unhappiness. The idea behind the strict_types directive was to combine two versions of the feature into one system, allowing users to switch between them at will. The proposal made clear that both modes have their advantages and disadvantages. A few of those were affected by compatibility with older code - in particular, around the behaviour of built-in functions - but those were not the main driving factors behind providing two modes. Perhaps, 5 or 6 years on, things have changed. Certainly, there are a vocal community of users who see "strict_types=1" as unreservedly "better" in some fundamental way - but then, there always were, that's why the debate was so heated. I rather suspect that most of the arguments put forward for one position or the other then are just as true now. I do wonder if people would even be asking the question, if the modes had been named something like "scalar_types=coerce" and "scalar_types=error", and somehow arranged such that neither was in force by default. [PS: What a beautifully timed e-mail - "11/11/2020 20:20 UTC"!] Regards, -- Rowan Tommins (né Collins) [IMSoP]