Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:121565 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 5817 invoked from network); 3 Nov 2023 13:16:09 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 3 Nov 2023 13:16:09 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 1DBD51804D5 for ; Fri, 3 Nov 2023 06:16:05 -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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,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: AS2639 136.143.184.0/24 X-Spam-Virus: No X-Envelope-From: Received: from sender3-of-o58.zoho.com (sender3-of-o58.zoho.com [136.143.184.58]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 3 Nov 2023 06:16:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699017362; cv=none; d=zohomail.com; s=zohoarc; b=AIkTcpIyTTorv1Lu6KoH+HhGlhvR1tFZKVXKkrv128zFRqIQJuQ8jrEOjsF1HqhBWJhugPujt9sCSKpbhsSEL++4/KxJBIcTAPFx0aCvAu0+buag2RWJcHM1hp8y/o4sWmUCl+lYr1PqsHBBjsgXD07Ikn1dpOxX90GHUIUWZSs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699017362; h=Content-Type:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=Upvo1AcSqYyITwxENhdnhwJ80Efwg1LMKYwwzxpugNc=; b=cYBMxA0UzIwNTxl/1K6civfXFTvRgD4+t2+BRskaDqKzgkiTfGP/lqrNBSnOFbZbU+5zqZ5bPuq6dchVjnAwF7GLjMd1eSB392p7o10I9HtUW5oDN6wOnvGyo+2NiuRlV3h+0Vc9Z4MkC2ir2IkvLOGeD0VbwbxhIGwevcnlEsU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=daniil.it; spf=pass smtp.mailfrom=daniil@daniil.it; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1699017362; s=daniil; d=daniil.it; i=daniil@daniil.it; h=Content-Type:Message-ID:Date:Date:MIME-Version:Subject:Subject:To:To:References:From:From:In-Reply-To:Message-Id:Reply-To:Cc; bh=Upvo1AcSqYyITwxENhdnhwJ80Efwg1LMKYwwzxpugNc=; b=aIuLm624JAboJ6IpmTkWcllTzvzu5uZWHmyl0iAL4F/FAI75cR6S6a0d2tJmflI2 rFEGE6m569z5nTvMQigfo+RYzf6mpUQW3DmF2uQ1UAas3byaejQ+dH0XDKPLg3EwjtS 2AmpzqFbhsWZob2pJrQhMw1ijuALi2iexUY7qfgQ= Received: from [192.168.69.130] (128.116.205.77 [128.116.205.77]) by mx.zohomail.com with SMTPS id 1699017359819968.5704654881371; Fri, 3 Nov 2023 06:15:59 -0700 (PDT) Content-Type: multipart/alternative; boundary="------------DqL1sSOsE50uvYqIMk6Ul7DW" Message-ID: <5ea314c4-f45d-4b7c-a94d-a82931eeb80b@daniil.it> Date: Fri, 3 Nov 2023 14:15:59 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: internals@lists.php.net References: In-Reply-To: X-ZohoMailClient: External Subject: Re: [PHP-DEV] Previous discussions about generics syntax only? From: daniil@daniil.it (Daniil Gentili) --------------DqL1sSOsE50uvYqIMk6Ul7DW Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi Ilija, > The optimizer, including type inference, is limited to the scope of > the current file (along with internal functions/classes). [...] > Preloading is the exception, where all preloaded files can assume not > to be changed after PHP has booted. Well, I was actually thinking of enabling these compile-time checks only if preloading is enabled, to ensure the closed-world guarantee. > We could make type checking a CLI step but how is that really better than > PHPStan or Psalm at that point Yeah don't really like the idea of a separate "typechecking" step either, I'd really love for this to be an integral part of the execution process, not as a separate static analysis step. > PHPStan and Psalm are arguably successful *because* they are > written in PHP, making them much easier to maintain and contribute to. Agreed, however if at least some static analysis functionality is already implemented, I see no reason to not make use of it, even if > PHP does not accurately represent arrays in the optimizer and has no notion of array shapes. personally I really like array shapes but *only* as a stopgap measure while switching to full object DTOs, so I'm comfortable with the idea of not having static analysis for array shapes (actually, I would absolutely love to just treat all array values as mixed during static analysis, though array/list generics might be nice and easy to implement...). > Another issue, specifically pertaining to generics, is that PHP has > type coercion. In both weak and strict typing mode, a float function > parameter will coerce an integer value. However, if generic types are > erased at runtime then the VM cannot do coercion for foo($int) > (where function foo(T $var)). This will require either accepting > inaccurate runtime types, or establishing stricter static rules that > do not match the existing behavior. Well I'm all for stricter rules :) Regards, Daniil Gentili. --------------DqL1sSOsE50uvYqIMk6Ul7DW--