Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123728 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id 138441A009C for ; Fri, 21 Jun 2024 13:17:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1718975905; bh=XM0mQfx6hH8+9ufhp0y/wLDvK+QRVzKvCUD42UkD96w=; h=In-Reply-To:References:Date:From:To:Subject:From; b=oJI6hvUnNmJucxCAlhgLeCfP4MAHx0IzdruFGAPOJy0GfQaNHDCSEGN/6xSqbWZRx JJP/zB+y5xge9FWJvhBVkH0LjKxhVfQyV3GKWubtdzoulfAtF4zA5bW9zL7NpkuDgX 5xGzZKZajJQWLLHMZrCTOWUJX+fZBpI9d8dNVVi6PaJq6RsQuVOrBemKLGf4PEYDxF 0czJqWAHXtRiAms5TN30q8UwmAz81u2grPp9cJ/rhIwTebJSQ/wzEukqu45q39dmO4 Ck9Pictuf5vSCVbBYj0pVgSlkf+GArkqGX4R85DnvGJXcpFcRoXkOPg2ERaHVuCZ/X yxl/XddMVCatA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 52327180704 for ; Fri, 21 Jun 2024 13:18:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,HTML_MESSAGE, RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from fout6-smtp.messagingengine.com (fout6-smtp.messagingengine.com [103.168.172.149]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 21 Jun 2024 13:18:23 +0000 (UTC) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailfout.nyi.internal (Postfix) with ESMTP id BB07F13800C1 for ; Fri, 21 Jun 2024 09:17:08 -0400 (EDT) Received: from imap50 ([10.202.2.100]) by compute6.internal (MEProxy); Fri, 21 Jun 2024 09:17:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rwec.co.uk; h=cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1718975828; x=1719062228; bh=exXBZGvQIF 3F7vDATE52LRWkDRgU1OkAGYMAF4kcUjk=; b=ns8RSr2qvlfM142h7B9Ow61KK1 nlWuxdQM1jV9h+XDitMaxRQylQIDuCU4/qoxQ8C0WQwJFbtHP2LCayixwjN82oMW V8VK11IP2xJJx+17UIfB3yJqOkRcXyRgPjo3rIgtYNyc1f67smS4UnFRHXgag5IE 2zEY4672lnHKAlfTGOEMAY2hWulTGlqjuPXsCpGJN6rTvefunedD6Of/623uk9Ih dgqOZa/JnfmXLkOjObwidw7uDSD4behsnoCMIDhGbFMB3fRJeSaFE1nMBG0/Ewws f+k68aqoI1Jm5V3oTPmRHTTG+qT3cQxWeOVnkd2m77T9qzWmvSpYk3u3kSdA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1718975828; x=1719062228; bh=exXBZGvQIF3F7vDATE52LRWkDRgU 1OkAGYMAF4kcUjk=; b=KD1kZixnaII7G753AuBayPges7YakHBQrn9okcMdTjX6 7oBu0XYlY+HOinSm3jRkLApF6V4ZugiQQnkAhOXXcLZ83l6+zYxbUUx4/3GdsXwx hvpHMF3A4nsyD6T1tuF//8AUuL+XPgKvjyw8YBxcrwmn/02rvn6zQub0a4D7DvjM 1HfwnozHydr1a51HoJodN4Oqj/6I0EdRbMupzxCXabzC8h94E4JlIJm8Akw5dKV3 RtagVrZib1P53snNq/jpWbewhrykOzm9M/S8dZ+pcU7k+F47cIWJHLYmCgiw9an9 ZXRlmy/1FR9DOnWyVS700LPmwaTPg9U1Yd5ukjQKig== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrfeefgedgieefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefofgggkfgjfhffhffvufgtsegrtd erreerreejnecuhfhrohhmpedftfhofigrnhcuvfhomhhmihhnshculgfkoffuohfrngdf uceoihhmshhophdrphhhphesrhifvggtrdgtohdruhhkqeenucggtffrrghtthgvrhhnpe eftdffkeekgfejhfffteegfefhvedukeegleefkeeuteekjedviefgueeuueeuudenucev lhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehimhhsohhprd hphhhpsehrfigvtgdrtghordhukh X-ME-Proxy: Feedback-ID: id5114917:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 4647E1700093; Fri, 21 Jun 2024 09:17:08 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.11.0-alpha0-522-ga39cca1d5-fm-20240610.002-ga39cca1d Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 Message-ID: In-Reply-To: <914cde73-3e53-44a8-94ff-bcf34000cc0c@processus.org> References: <9d28c9tOCChpWUcP1SFiFwtf2-w2XAtDzHsmM73myA7zfBsn7TxxEqs-VCnxRAgZjsk2TxS55owmM8wSLgBQL8LgeQLntUQ9toeLMkjTVx4=@gpb.moe> <673a1803-83c4-44b4-bd73-4ba61e83412e@app.fastmail.com> <350c1531-9bcf-4e7c-824b-8d9904b9e48e@rwec.co.uk> <914cde73-3e53-44a8-94ff-bcf34000cc0c@processus.org> Date: Fri, 21 Jun 2024 14:16:26 +0100 To: internals@lists.php.net Subject: Re: [PHP-DEV] Renaming "strict types" to "scalar type coercion" Content-Type: multipart/alternative; boundary=038c512fb6054b429fa43f2452b85dc8 From: imsop.php@rwec.co.uk ("Rowan Tommins [IMSoP]") --038c512fb6054b429fa43f2452b85dc8 Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable > Le 21/06/2024 =C3=A0 14:27, Robert Landers a =C3=A9crit : >> This is why I wanted to work on "as" part of the pattern matching. It >> isn't clear what will happen with the actual pattern matching RFC >> (yet), but being able to do: >>=20 >> some_function_expecting_int($_GET['foo'] as ?int); I've started drafting a proposal for strict casts - independent of the p= attern matching effort, but might be combinable - but the devil's in the= details of exactly when the cast should fail, and what should happen wh= en it does. For instance, should cast('abc' as ?int) fail, or default to null? Do we= need different syntax for both? I have some thoughts, but haven't quite= settled on a full proposal yet. On Fri, 21 Jun 2024, at 13:46, Pierre wrote: >=20 > And how about: >=20 > some_function_expecting_int(\intval($_GET['foo'])); intval($foo) and (int)$foo do exactly the same thing; they're basically = just different syntax. >=20 > And moreover, I'd write something like this, but: >=20 > function validate_int(mixed $value): int { ... Which is why I included the word *concise*: it shouldn't be necessary fo= r every user to write or install a custom function for such a common req= uirement. Regards, --=20 Rowan Tommins [IMSoP] --038c512fb6054b429fa43f2452b85dc8 Content-Type: text/html;charset=utf-8 Content-Transfer-Encoding: quoted-printable
Le 21/06/2024 =C3=A0 14:27, Robert Landers a =C3=A9crit :
This is why I wanted to work on "as" part o= f the pattern matching. It isn't clear what will happen with the actual pattern matching RFC (yet), but being able to do: some_function_expecting_int($_GET['foo'] as ?int);


I've started dra= fting a proposal for strict casts - independent of the pattern matching = effort, but might be combinable - but the devil's in the details of exac= tly when the cast should fail, and what should happen when it does.
<= /div>

For instance, should cast('abc' as ?int) fail, = or default to null? Do we need different syntax for both? I have some th= oughts, but haven't quite settled on a full proposal yet.
=


On Fri, 21 Jun 2024, at 13:= 46, Pierre wrote:

And how about:

some_function_expecting_int(\int=
val($_GET['foo']));


=
intval($foo) and (int)$foo do exactly the same thing; they're basic= ally just different syntax.



And moreover= , I'd write something like this, but:

function validate_int(=
mixed $value): int { ...


<= /div>
Which is why I included the word *concise*: it shouldn't be ne= cessary for every user to write or install a custom function for such a = common requirement.

Regards,
= --
Rowan Tommins
[IMSoP]
--038c512fb6054b429fa43f2452b85dc8--