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 <internals@lists.php.net>; 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 <internals@lists.php.net>; 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: <imsop.php@rwec.co.uk>
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 <internals@lists.php.net>; 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 <internals@lists.php.net>; 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: <xms:VH11ZiGyhGNh-MOx0nBluEflRzyc_DBYR0irA-Mb4U9xCtJ33696YA>
    <xme:VH11ZjWa67O025H5d3QctZY4dW_C0CES-06ASLLVlkj3-L6aLEP3WZ1x81u0tuq6E
    5y53CG81Bb8A5kOazE>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrfeefgedgieefucetufdoteggodetrfdotf
    fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen
    uceurghilhhouhhtmecufedttdenucenucfjughrpefofgggkfgjfhffhffvufgtsegrtd
    erreerreejnecuhfhrohhmpedftfhofigrnhcuvfhomhhmihhnshculgfkoffuohfrngdf
    uceoihhmshhophdrphhhphesrhifvggtrdgtohdruhhkqeenucggtffrrghtthgvrhhnpe
    eftdffkeekgfejhfffteegfefhvedukeegleefkeeuteekjedviefgueeuueeuudenucev
    lhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehimhhsohhprd
    hphhhpsehrfigvtgdrtghordhukh
X-ME-Proxy: <xmx:VH11ZsKeGF6VP3Tz9QGJykVH95s9jwRSHhM81ygj-_OYOMjzWzB6Xw>
    <xmx:VH11ZsFQ2Qq98sgb61tILXgElxKJumoqy8oer1nRuv66lbX3yIdqeg>
    <xmx:VH11ZoWMROnuDPaQoTE9-vPt3zfi5LKjfWKmNeHlmoCa21ipo9-enA>
    <xmx:VH11ZvPu8UkSN8DdFYgxvsDNW9xHrOmdgT4A5Q1Tim7K4-gB8Ah30Q>
    <xmx:VH11ZhcSHgR8_jU11X3wCM0co6aVsW_xB5bjMvzXU46WomMqOLjAPD8A>
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: <mailto:internals+help@lists.php.net
list-unsubscribe: <mailto:internals+unsubscribe@lists.php.net>
list-post: <mailto:internals@lists.php.net>
List-Id: internals.lists.php.net
MIME-Version: 1.0
Message-ID: <a65f9149-a58d-4798-b3b2-2e3a8755520c@app.fastmail.com>
In-Reply-To: <914cde73-3e53-44a8-94ff-bcf34000cc0c@processus.org>
References: 
 <CAPzBOBMidokE3xw251f+_qbCPAyQQRcN1WnyVF0xfuzaPBU3JA@mail.gmail.com>
 <9d28c9tOCChpWUcP1SFiFwtf2-w2XAtDzHsmM73myA7zfBsn7TxxEqs-VCnxRAgZjsk2TxS55owmM8wSLgBQL8LgeQLntUQ9toeLMkjTVx4=@gpb.moe>
 <673a1803-83c4-44b4-bd73-4ba61e83412e@app.fastmail.com>
 <350c1531-9bcf-4e7c-824b-8d9904b9e48e@rwec.co.uk>
 <CAPzBOBMw=Hn4SabAq0FeppLpQMwRJh2Ffc3JhhFFOps85XNazw@mail.gmail.com>
 <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

<!DOCTYPE html><html><head><title></title><style type=3D"text/css">p.Mso=
Normal,p.MsoNoSpacing{margin:0}</style></head><body><blockquote type=3D"=
cite" id=3D"qt" style=3D""><div class=3D"qt-moz-cite-prefix"><div class=3D=
"qt-moz-cite-prefix">Le 21/06/2024 =C3=A0 14:27, Robert Landers a
      =C3=A9crit&nbsp;:<br></div><blockquote type=3D"cite" cite=3D"mid:C=
APzBOBMw=3DHn4SabAq0FeppLpQMwRJh2Ffc3JhhFFOps85XNazw@mail.gmail.com"><pr=
e class=3D"qt-moz-quote-pre">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);<br></pre></blockquot=
e></div></blockquote><div><br></div><div><br></div><div>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.<br><=
/div><div><br></div><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.<br></div><div>=
<br></div><div><br></div><div><br></div><div>On Fri, 21 Jun 2024, at 13:=
46, Pierre wrote:<br></div><blockquote type=3D"cite" id=3D"qt" style=3D"=
"><div class=3D"qt-moz-cite-prefix">
<br></div><p>And how about:<br></p><pre>some_function_expecting_int(\int=
val($_GET['foo']));<br></pre></blockquote><div><br></div><div><br></div>=
<div>intval($foo) and (int)$foo do exactly the same thing; they're basic=
ally just different syntax.<br></div><div><br></div><div><br></div><bloc=
kquote type=3D"cite" id=3D"qt" style=3D""><pre><br></pre><p>And moreover=
, I'd write something like this, but:<br></p><pre>function validate_int(=
mixed $value): int { ...<br></pre></blockquote><div><br></div><div><br><=
/div><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.<br></div><div><br></div><div>Regards,<br></div><div>=
-- <br></div><div>Rowan Tommins<br></div><div>[IMSoP]<br></div></body></=
html>
--038c512fb6054b429fa43f2452b85dc8--