Newsgroups: php.internals
Path: news.php.net
Xref: news.php.net php.internals:122711
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 2A7541A009C
for ; Thu, 21 Mar 2024 16:30:21 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail;
t=1711038642; bh=SzmuTAxH2d/jkotZxpYM7getuEOq23tCHvUT9FZGEm4=;
h=Date:Subject:To:References:From:In-Reply-To:From;
b=FxiY13BzfBCNonO88UfDnDUZmxFmGiLuHUHA9WmkmbRct7I1QFx7KU9vABdZJBLbO
q1/wcS9vHEvxffeFl2WK62/jm7VCtpqPYn5XyVrrRBrV2Y+YmIGa2xSm2dItzjeHLb
RlN3Qu4OYb9L8Kez4AvewxwnyE85ZqnRZW9AyHCb+l5h0sfyGNgdznz2b7sly11RsT
bLZSwyv4BcD7r3TZRB744vrTR5s0U2x2lDv52cBdGOvWVJCnZ7w/Di77spA1ZE3S+d
q5oFf50FAgVxj112FbW+HI/SqFESZ6LzYrFrg8d4KhEyKUjNHHRQQdph2w00TY2qwI
GXLPObDYw7Gnw==
Received: from php-smtp4.php.net (localhost [127.0.0.1])
by php-smtp4.php.net (Postfix) with ESMTP id 2C50C180840
for ; Thu, 21 Mar 2024 16:30:41 +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.9 required=5.0 tests=BAYES_40,DKIM_SIGNED,
DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,HTML_MESSAGE,
RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE
autolearn=no autolearn_force=no version=4.0.0
X-Spam-Virus: No
X-Envelope-From:
Received: from fout2-smtp.messagingengine.com (fout2-smtp.messagingengine.com [103.168.172.145])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256)
(No client certificate requested)
by php-smtp4.php.net (Postfix) with ESMTPS
for ; Thu, 21 Mar 2024 16:30:40 +0000 (UTC)
Received: from compute7.internal (compute7.nyi.internal [10.202.2.48])
by mailfout.nyi.internal (Postfix) with ESMTP id 4C6AA138014B
for ; Thu, 21 Mar 2024 12:30:18 -0400 (EDT)
Received: from mailfrontend2 ([10.202.2.163])
by compute7.internal (MEProxy); Thu, 21 Mar 2024 12:30:18 -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=1711038618; x=1711125018; bh=NMhByulIE5
mjNr80D4ave4NKC9RZihF8saiqKHR+W0c=; b=PivRPolSBn6UIkVusByqNlUzFJ
GqDYQJyt3OA4FzMJDG0QZu4gsLlva02br8V8MPRFKo04xLS538Uf9RUBqIBMYxr+
sUqpAVwt6/wCMgULGxxeoaVqPrJxTt8zE4XFNIWrpsFScpXR3D1yzBolp+fv0u6m
C4hQT484ZSHr/S4vcAstPS14FFVk1I24vTj6NJ6YzI7k2lB/rnVVPYhm7X+ffrrs
VupJ64uqDDB1mAiLWUBKdULRfH5QU1WGOUwigC63uI0DyqTy4nfPETZaXmPGknl8
f8VOuIryHZldmhAfRNQRcmh/Oo5A+6/Mqv+7fETSLoWUd49h3NrPuYVQx18w==
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=1711038618; x=1711125018; bh=NMhByulIE5mjNr80D4ave4NKC9RZ
ihF8saiqKHR+W0c=; b=YELmr7EyGtqeaIKyAptcyM1rP5ZSW/XsWHo731o3fTrr
baZdxwHfneU2Q5bPyynXiaPdEknPowoQk6UXTuolTW8Zgs6R/M5hT177RveLwxit
7ufZEpALfwSVuw8MqKYrPAGtk3ZtBUDkmJvJnw2UlObJR4/4e6hPMlb9RhwtdzOE
HNu8XH7AZuKOoMgrW0fR3jW8UTTItBvD0YahmO0Rf17VNVvgM4hQmMe/5K4Ruv8j
pkIE/Y0xa0uosHCws+kcFa9LEhkXLtPu8e37jweZeG1R+ykkIztpfDsUG6hDR+Wk
loPQeKeympjWDCVII7+stZ6MoVoCDisNO5bcF+0jiQ==
X-ME-Sender:
X-ME-Received:
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrleejgddvjecutefuodetggdotefrodftvf
curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu
uegrihhlohhuthemuceftddtnecuogfuuhhsphgvtghtffhomhgrihhnucdlgeelmdenuc
fjughrpegtkfffgggfuffvfhfhjgesrgdtreertddvjeenucfhrhhomhepfdftohifrghn
ucfvohhmmhhinhhsucglkffoufhorfgnfdcuoehimhhsohhprdhphhhpsehrfigvtgdrtg
hordhukheqnecuggftrfgrthhtvghrnhepfeettdekhfdukeeufeevgeduveejieeigfdt
ffejheduteekveehjeekieeuffegnecuffhomhgrihhnpeefvheglhdrohhrghenucevlh
hushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehimhhsohhprdhp
hhhpsehrfigvtgdrtghordhukh
X-ME-Proxy:
Feedback-ID: id5114917:Fastmail
Received: by mail.messagingengine.com (Postfix) with ESMTPA for
; Thu, 21 Mar 2024 12:30:17 -0400 (EDT)
Content-Type: multipart/alternative;
boundary="------------ruC0D471Ju0107M0H0gexGRl"
Message-ID: <40d5c22f-5c06-403d-afc2-84c202277a29@rwec.co.uk>
Date: Thu, 21 Mar 2024 16:30:15 +0000
Precedence: bulk
list-help:
list-post:
List-Id: internals.lists.php.net
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: [PHP-DEV] Proposal: AS assertions
To: internals@lists.php.net
References:
<3F78A125-1946-42E2-A4F5-A2B282BE2107@rwec.co.uk>
<2d7ec203-6e80-445c-94f4-d29ef58743b1@rwec.co.uk>
Content-Language: en-GB
In-Reply-To:
From: imsop.php@rwec.co.uk ("Rowan Tommins [IMSoP]")
This is a multi-part message in MIME format.
--------------ruC0D471Ju0107M0H0gexGRl
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
On 21/03/2024 15:02, Robert Landers wrote:
> I don't think you are getting what I am saying.
>
> $a as int|float
>
> would be an int, float, or thrown exception.
>
> $a as int|float|null
>
> would be an int, float, or null.
I get what you're saying, but I disagree that it's a good idea.
If $a is 'hello', both of those statements should throw exactly the same
error, for exactly the same reason - the input is not compatible with
the type you have specified.
> Another way of thinking about is:
>
> $x = $a as null
>
> What do you expect $x to be?
The same as $x inside this function:
function foo(null $x) { var_dump($x); }
foo($a);
Which is null if $a is null, and a TypeError if $a is anything else:
https://3v4l.org/5UR5A
Regards,
--
Rowan Tommins
[IMSoP]
--------------ruC0D471Ju0107M0H0gexGRl
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit
On 21/03/2024 15:02, Robert Landers
wrote:
I don't think you are getting what I am saying.
$a as int|float
would be an int, float, or thrown exception.
$a as int|float|null
would be an int, float, or null.
I get what you're saying, but I disagree that it's a good idea.
If $a is 'hello', both of those statements should throw exactly
the same error, for exactly the same reason - the input is not
compatible with the type you have specified.
Another way of thinking about is:
$x = $a as null
What do you expect $x to be?
The same as $x inside this function:
function foo(null $x) { var_dump($x); }
foo($a);
Which is null if $a is null, and a TypeError if $a is anything
else: https://3v4l.org/5UR5A
Regards,
--
Rowan Tommins
[IMSoP]
--------------ruC0D471Ju0107M0H0gexGRl--