Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115495 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 21642 invoked from network); 19 Jul 2021 14:03:08 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 19 Jul 2021 14:03:08 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E875A1804F4 for ; Mon, 19 Jul 2021 07:28:08 -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.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A, RCVD_IN_DNSWL_LOW,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 mout.gmx.net (mout.gmx.net [212.227.15.19]) (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 ; Mon, 19 Jul 2021 07:28:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1626704886; bh=xZnzcL9EoYFShoMUumyN56+E4kHfJg74Qcpe0ou0jrk=; h=X-UI-Sender-Class:Subject:To:References:From:Date:In-Reply-To; b=ZYsNaawiXH6vkayP0DD2g54f/j2YYnlKSPnq0Fngnn/DQdH1K+GJtgyv+coxN5KCE 3UcrAj07heuAdG2jNGMya6Q4N09Z7b1zWINzTwBdspDK5WJuVLxe9vUKw71BflBdxl i+NXseuKooGD4BLnpBDzkwtKXy/NuBlRZWAytTRw= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.178.120] ([24.134.51.41]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MHG8g-1lsL5S31Ps-00DGBY for ; Mon, 19 Jul 2021 16:28:06 +0200 To: internals@lists.php.net References: Message-ID: Date: Mon, 19 Jul 2021 16:28:17 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Content-Language: en-US X-Provags-ID: V03:K1:mVFMGQ9s3om/F11TFdmhFJJaT6RkAJXouSLIskla6JXuKrdAoAl hKcHdd8Khnc2Pux9heQiyhgBGiwJs7kXAYMIVf4E0aEtawJ3FVg/UtmyVFrLWCeY2e0RHtZ fzpg/4Vyvalnnfpx0NvKOdYqXprq4ycv+l/eyfrQwJV/3gvuygbffWzjVkEKFF9O0xrYBMT 9RciZtyHffzkHTjzZKqDQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:O+CE7F/iE6E=:mgznrjBhygGkTmGWFsH5rJ YGXttIu3SrK5S0fAwhx+WddbjtlsbroECutlf62b0bE5TolUyabWHW/+xys32gltGhPUrAi6K sUw95lZJV8/oTKYxeUUWTUZ4CkI3l71kSh5thaz/lbJFrDcWeLNRwb4jrL4OUiEkqZfkRIoi5 R6u2CsHG/CBN7DEilHPR8onbXsREffuctoJl19SHTelBTqOn12IjzZy749NmMssOmct9sACNe l4L2Ye6r+nt0PiQ53O3u6DUlTL0MAPeeAzeUCvJo8XELh2ANa/XLFhlif+RSrSAvO+U4Sv+C+ 5NtC1iKB0D/Yd0MHMXR+VkW/ZW4JmHBMGs3BP0ThYrPZp8rfh61eCVgf34GETIpoQ+62OZDdS HfOIyEBa/YKwB0m3iuW5DiHCQi0Ih/T/UAQ3mR+ik5wagjtOqWFyyT2RnoVXZV6Jtx8tetfsB fmQzznWC4IO2CLKZ6vSmIdZFUKayIpASIF/YAifIW1PEFQxFmptVE0qKOSF5EC1Q6pTMWEuIV uUERyiae8W4JCv+c4F0CpgviptSWiBlgBWek1ZFCs31DhZBcNhqKHYVzO83RWPUQAws0Ru/+b B1y450IKCwlWikAFwKN52YwCwfNCkTq5uJFGxjmtZif4fzkSf3VWfQOj+tvuJ9RYnmN9Ecjed XOQdqf3zHxn6qcq4HXy2nIuN3w6vue5PaCPwTWR3S0ySGxAT42QhGO+mPm4m686ZniVVsBHW+ 671327oxIQoL3BrxP5D6EX4D4avPpanIVX36b9SKeSG/1P7E/bRrk45Htx1lY9JLnamBvH16w dOa/caBRyuTZw5JHaFUNiOugQQy3PRvVlCuvXTSqs6hOSYhCXtK363/8ij9ifIYgW3STivCvM moR3Be066WYHpuFqWf/QkZiZJpxbRHgH8wvDLLQD7S5hthJk4CbxX1/6uLTOlv6dhNXbVJoAg hRIc9D3QrcmOhsN0K5PfUDdu64lUQVTCa9Oe5CC67Ok3Uwf1vme6shMj7YBP01h7EM+GsbADw aSxBAiUCRElN7WYYwH0M+GM23I9oz99KI66D82HAN3LGcFD2+K5TMWFF3Gpyr+HFF8x/vuVmd KIe6yjTPyYhbOyDmoejNMn8MaXrRNnpF+EP Subject: Re: [PHP-DEV] intersection types and null for defaults, properties and return types From: a.leathley@gmx.net (Andreas Leathley) On 19.07.21 11:21, azjezz wrote: > however, when `T` is an intersection between `X` and `T` ( `X&Y` ), `X&Y= $x =3D null` becomes `null|X&Y $x =3D null`, which is a combination betwe= en union and intersection types, however, as the RFC stats, currently comb= ination between union and intersection types is not support ( hence "pure"= ). > > for this to be allowed, PHP would need to support combining union and in= tersection types, preferable using parenthesis ( `X|(Y&Z) $x =3D null` or = `(X&Y)|Z $x =3D null` ). > Supporting a syntax like ?A&B could just be a special case just like ?A was in the past, before actual union types existed. I can see how full support for union types and intersection types can get complicated (and may never make it into PHP, or need quite some time until it does), but pure intersection types that can be nullable seems like a relatively simple special case which would be very helpful in code, because you could have optional intersection types in arguments/properties, which is otherwise not possible (and one would have to fall back once again to annotations and less type safety). Nullable intersection types also do not touch upon the main problems of mixing union types and intersection types, namely in reflection, where it would just lead to "ReflectionType::allowsNull" to be true instead of false, but not change any other logic as far as I can tell.