Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:120950 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 79502 invoked from network); 29 Aug 2023 16:40:49 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 29 Aug 2023 16:40:49 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 075DB1804D4 for ; Tue, 29 Aug 2023 09:40:49 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-oo1-f52.google.com (mail-oo1-f52.google.com [209.85.161.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-256) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 29 Aug 2023 09:40:48 -0700 (PDT) Received: by mail-oo1-f52.google.com with SMTP id 006d021491bc7-5712b68dbc0so2875379eaf.1 for ; Tue, 29 Aug 2023 09:40:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693327248; x=1693932048; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=eUNocQHiWQBgXJBkX9rk2SHO7UV2gj87rYXlJtokO28=; b=oko9NZ4+/CZhu5NhoPMsN2jl4ZMk5hUIHADx9wvU4rZB6d0M+bcASseUdY4UWbELfq Xp6nUmU3OLl7mZVOCkqrfIPqCxKWAq9z/8mmvAQIidrdrqDsBwgqtyonHS8GcKEYtirD SfZqYzc6wCYmtTMtRpBKApmFDRQk3DyGFnpR5232h8VIXfKj4w2fqqAn4iONDbOMY0kj OcAzm4c0Ikhi0zDzvA6k4rHhTRD3+eFzFlADtGj5VxcmDGJjM9ByUZe19oCV7zApQVYH SP1Bsa6S9zUGxSdjPMgmuRyOwbmzJoSy2J3YG+4IU0dsiR4ZDm0txl7z9Z1Dx6m601XO KZew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693327248; x=1693932048; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eUNocQHiWQBgXJBkX9rk2SHO7UV2gj87rYXlJtokO28=; b=QhOtoyxY+YQ9g96sf51/NvZA01NDyFgfA+Z2QyAvwSwtQ0n9F0aB+M7BUBe3PnJU87 9bzNcpN9akYznEknG9Quc6AqNqrAwJFk0h+i6b7ipMLMe/bmBYRnlDgvanb+5oFbZOHz Zdyhusiv63PIpLMy98NP7P52MA2ITSW90dwDKyRv97KTkFYfLx91QQWvOaWLvM8hu3gG /UgBg4iH8HhZpx0+cL7yvdGCy8cAjbGmxNpRYIQh/PcVLmEISV4oE+jyf3lHH3IYeLOD Tgkcg9Vzv12F4CRY5AwdE65WW5rDGYc3+E0XBVwzYnlqF/bd7ud0DVDTL1magyGi9hdu dXUQ== X-Gm-Message-State: AOJu0YxvcUH1fBsVNCX/OK0iqgvnMTtNb6LYdzuTZXgMpqErI4IC3MHu gxmPx8NtRAIkHlFEgkzdri58S1/UEW/ixaTGx1M= X-Google-Smtp-Source: AGHT+IE6dzXE2mRCbhOBiXNFy8JvSz9eHoIePW8JYRm2GQde/FrhTu6UK5MX2w3Qewp7gguVxTJGKgfPBAKp4YaBLMA= X-Received: by 2002:a4a:2a1c:0:b0:571:260e:ab69 with SMTP id k28-20020a4a2a1c000000b00571260eab69mr14545822oof.2.1693327247937; Tue, 29 Aug 2023 09:40:47 -0700 (PDT) MIME-Version: 1.0 References: <4406C50C-18FF-4F20-BA7B-206E86610CCC@sakiot.com> <245BD1CC-7D54-4CBE-9640-5C8FF5225617@gmail.com> <5B8A7736-9A2A-47E1-B410-4D734DC75EBE@gmail.com> In-Reply-To: Date: Tue, 29 Aug 2023 18:40:12 +0200 Message-ID: To: Claude Pache Cc: Saki Takamachi , PHP internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Apply strict_types to internal functions From: divinity76@gmail.com (Hans Henrik Bergan) * I think most code actually using strict_types=3D1 is built with the assumption that internal functions use strict too, so it's entirely possible that the backwards-compatibility issue is so small that we can get away with internal functions just inheriting the userland strict_types On Tue, 29 Aug 2023 at 18:36, Hans Henrik Bergan wro= te: > > maybe we could do a > declare(internal_strict_types=3D1); > on a per-file basis just like the existing userland strict_types? > (name is up for bikeshedding ofc) > > On Tue, 29 Aug 2023 at 17:49, Claude Pache wrote= : > > > > > > > > > Le 29 ao=C3=BBt 2023 =C3=A0 15:19, Saki Takamachi a= =C3=A9crit : > > > > > >> Hi, > > >> > > >> The larger issue is that higher-order functions do not inherit the `= strict_types` mode from its calling code, and this is not specific to inter= nal functions. > > >> > > >> If you intend to change that for internal functions (with proper dep= recation period, of course), you might consider making such a behaviour als= o possible for userland functions (probably using some opt-in); so that fut= ure higher-order internal functions do not become impossible to polyfill. > > >> > > >> =E2=80=94Claude > > > > > > Hi, thank you for confirming. > > > > > > If you simply put the problem you pointed out in the code, would it b= e something like this? > > > https://gist.github.com/SakiTakamachi/8292dbfe92a2029a6c7b506b12296b7= d > > > > > > Admittedly, I don't think this is intuitive either. > > > > That might not be intuitive to you, but it follows directly from the sp= ecified semantics: whether a function is called in `strict_types` mode or n= ot, depends only on where the function is called. I personally doubt that t= here is an easy way to adjust the rule in order to make it both =E2=80=9Cin= tuitive=E2=80=9D and simple. > > > > > > > > [...] > > > > > > When considering the inheritance of strict_types, I think that it sho= uld be an attribute that can be set in =E2=80=9Cphp.ini" instead of being s= pecified for each file. > > > > > > What do you think? > > > > Beware that there are many third-party packages that have not opted for= `strict_types=3D1`; if you enable that mode globally, you might make those= packages malfunction. > > > > As I have just checked, among the packages I=E2=80=99ve installed via c= omposer, there are more packages that do not use `strict_types=3D1`, than p= ackages that use it. Among those that don=E2=80=99t use `strict_types`, the= following ones are fairly common: > > > > google/apiclient > > league/oauth2-client > > michelf/php-markdown > > microsoft/microsoft-graph > > phpmailer/phpmailer > > phpoffice/phpspreadsheet > > phpseclib/phpseclib > > > > =E2=80=94Claude > > > > -- > > PHP Internals - PHP Runtime Development Mailing List > > To unsubscribe, visit: https://www.php.net/unsub.php > >