Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115490 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 13323 invoked from network); 19 Jul 2021 13:40:05 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 19 Jul 2021 13:40:05 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 8D732180502 for ; Mon, 19 Jul 2021 07:05: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.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) (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:05:04 -0700 (PDT) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id D4F9B320085B for ; Mon, 19 Jul 2021 10:05:03 -0400 (EDT) Received: from imap43 ([10.202.2.93]) by compute1.internal (MEProxy); Mon, 19 Jul 2021 10:05:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=4QrQb0 W6rZkkbB+RIw1xDE5awBZOK5AgmArlr7RilJ0=; b=eFOHC924BLq0OM3DHf94YX KP8LUhFoGyrwCIyFA8WAvp0TnzJtJxetv9Vg50Xd2M1bxie3JrbUcorOmdWoTVVY Vw8DiTayOnqnBp/GA6YJW0ArLnd8w0Gy88DGe0SQkOW2v7fSj17v1Hw2DEv5cpDY 4lQAXT4oPJaz+z4UKd54F+PIZXBmYzvjVHP91DfYag/Ybfq84S5sNG6RDQ3wU+Aw dQb4lR28xX7oH5SmPy9YVG7zFSpktaBLUist/a574XmJLbdpHAo611CnRdyMGiqf x4NJqGf7TW5BViuHqjHT8vxqWHh3aoywJn32QF4p9aLgb8C+uh0lxQrUNBPganIg == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrfedtgdejtdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefofgggkfgjfhffhffvufgtsehttdertderreejnecuhfhrohhmpedfnfgrrhhr hicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomh eqnecuggftrfgrthhtvghrnheplefhjeduueegudeghfehudfgvdeflefffeeuteevuedt jeffkeetkeeiveejkefgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrg hilhhfrhhomheplhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhm X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 51424AC0D86; Mon, 19 Jul 2021 10:05:03 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.5.0-alpha0-533-gf73e617b8a-fm-20210712.002-gf73e617b Mime-Version: 1.0 Message-ID: In-Reply-To: References: Date: Mon, 19 Jul 2021 09:04:42 -0500 To: "php internals" Content-Type: text/plain Subject: =?UTF-8?Q?Re:_[PHP-DEV]_intersection_types_and_null_for_defaults,_proper?= =?UTF-8?Q?ties_and_return_types?= From: larry@garfieldtech.com ("Larry Garfield") On Mon, Jul 19, 2021, at 4:21 AM, azjezz wrote: > Hello, > > I personally don't consider a bug, but an expected behavior. > > when writing: > > ``` > T $x = null > ``` > > it is the same as writing: > > ``` > T|null $x = null > ``` > > or > > ``` > ?T $x = null > ``` > > however, when `T` is an intersection between `X` and `T` ( `X&Y` ), > `X&Y $x = null` becomes `null|X&Y $x = null`, which is a combination > between union and intersection types, however, as the RFC stats, > currently combination between union and intersection types is not > support ( hence "pure" ). > > for this to be allowed, PHP would need to support combining union and > intersection types, preferable using parenthesis ( `X|(Y&Z) $x = null` > or `(X&Y)|Z $x = null` ). > > Regards, > > Saif. I can see the argument that "I need something with these two interfaces... or nothing" is a valid use case to care about. However, as Saif noted, this is a side effect of the inability to mix union and intersection types. So, my question would be, how feasible will it be in the future to introduce that mixing? If it's something that is likely to show up in 8.2 or 8.3, we may be better off going "meh" for now and letting a solution fall out naturally later. If it's something that could take a decade, then figuring out a way to special case "or null" in the meantime is probably worthwhile. (I don't know what the best way to do that is.) --Larry Garfield