Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:120656 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 30052 invoked from network); 22 Jun 2023 03:08:24 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 22 Jun 2023 03:08:24 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 7EB79180339 for ; Wed, 21 Jun 2023 20:08:23 -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.3 required=5.0 tests=BAYES_00,BODY_8BITS, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS19151 66.111.4.0/24 X-Spam-Virus: No X-Envelope-From: Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) (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 ; Wed, 21 Jun 2023 20:08:22 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id AFD805C013C for ; Wed, 21 Jun 2023 23:08:21 -0400 (EDT) Received: from imap50 ([10.202.2.100]) by compute4.internal (MEProxy); Wed, 21 Jun 2023 23:08:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm2; t=1687403301; x=1687489701; bh=dBbsn/AwSl e2EmqKyhe64EmcYroKnuf8qQD+6HiSPNE=; b=C0W/vFa93ZA1cdHQ42jTaHdCeq a0WcOdY71E5Y0Rws16fFscCfFd27QnRFJFQ4d7YQ8GV+Z3/pbqQDH72uRBV9gf/R IH11NzB8F9EQGCXbIv1KCznf9CMEeietrOvuF/BHmQWcOw2ZPMy77slRfbokSPR5 O2nQ6o4TFOZV/Co2A5qD8jHukIKZF4yTI+WZAqMZfd9vQZiBRexHx4KZyldhL8q7 2EUc7w1UuAGC/qdoeAKNCxnrS/cAk+PP3pAgyvI492q839b5i4LioYys+0VIJon6 yJjQH3fXjJbPNUWzq09x26TFJJYVXN97cQ4yMUrkU+BXDM+dpU4aamNQ8I2A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1687403301; x= 1687489701; bh=dBbsn/AwSle2EmqKyhe64EmcYroKnuf8qQD+6HiSPNE=; b=X cfokMWpE7ej4LQj5Lu9ektecgcXGCq/3va8P4YsdmdstA4v4aARyXZgM/33IVl13 TEHXufeuhyRwDowpJYBD6toKP4vtsbrrO1JZ6LGPFB6rWPJHhw1Y/zBLKSg9kbFY KZiQUmcZahq02Cv6128dOC5HAjXszUTEySsg1tdv/qWtcaNyrzDeckymAn5fySOD 8ME7lzgBErSJJxzsqHtb4k8cD7zM6/UZp0t6F+WtINHc8tLPPjqB6n7y1IRCeI8W A2UgE0T7RSiXPPHr5/PCwHxGScbsfqSJ2AQnsiV7A/tgbO8j9mV/ZdQ9z7VYIUyu LqVnL//tWn+zijG/k2i6A== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrgeegtddgiedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgfgsehtqhertderreejnecuhfhrohhmpedfnfgr rhhrhicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtg homheqnecuggftrfgrthhtvghrnhepgeeghefgteejheeggfeghfelueeggfdtjeeivedv tefhveeguedufeelhedvteeinecuffhomhgrihhnpehphhhprdhnvghtnecuvehluhhsth gvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheplhgrrhhrhiesghgrrhhf ihgvlhguthgvtghhrdgtohhm X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 65FDD1700096; Wed, 21 Jun 2023 23:08:21 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.9.0-alpha0-499-gf27bbf33e2-fm-20230619.001-gf27bbf33 Mime-Version: 1.0 Message-ID: <3ac76b97-11c9-4408-9e2c-89ab61f0d59b@app.fastmail.com> In-Reply-To: References: Date: Wed, 21 Jun 2023 22:08:00 -0500 To: "php internals" Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [Proposal] Introduce is operator From: larry@garfieldtech.com ("Larry Garfield") On Wed, Jun 21, 2023, at 5:44 PM, =D0=A3=D0=B4=D0=B0=D0=BB=D1=8C=D1=86=D0= =BE=D0=B2 =D0=92=D0=B0=D0=BB=D0=B5=D0=BD=D1=82=D0=B8=D0=BD wrote: > Hi internals, > > Today PHP is more typed than ever, however, one feature is still missi= ng: > ability to check complex variable types using standard type declaratio= ns. > > For example, to check that $var is a nullable string one has to do > `assert($var =3D=3D=3D null || is_string($var))`. To check that $var i= s false or > a countable iterator, one has to write `assert($var =3D=3D=3D false ||= ($var > instanceof Countable && $var instanceof Iterator))`. > > I propose to add a new "is" operator that allows to have `assert($var = is > ?string)` and `assert($var is false|(Countable&Iterator))`. So it is > similar to instanceof, but accepts any valid PHP type declaration on t= he > right side. > > WDYT? > > Regards, > Valentin There's already an RFC for that in the works, from Ilija and I: https://= wiki.php.net/rfc/pattern-matching "In the works" in this case means it's been designed and some preliminar= y code written a while ago, but nothing submittable yet. We're hoping t= o get back to it in 8.4, as it's going to be a prerequisite for ADTs bei= ng usable. (cf: https://wiki.php.net/rfc/tagged_unions, though the desi= gn there is out of date.) So... hopefully stay tuned. --Larry Garfield