Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122730 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 4B5D81A009C for ; Fri, 22 Mar 2024 17:38:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1711129142; bh=3Ed/cqfB9Q25Qf0rO5Wpm4J7JeRMJz0RURS31xHlfi4=; h=From:Subject:Date:In-Reply-To:Cc:To:References:From; b=fY6Nw+h9uAK91F7Uu7i3aJ57rnGnDORyIkVRdm51RAhBSbLrLZ6DHzZxuuLJQJcil d4VPMlIwlzLqlAKuUWbPGGQnk/8oHc9QROjYP0Uh3Q4Cj0ftAJXhkGeIay8y4IaBy1 Bg5RRm+xlIbQA/ehJcZwYzBnFbkCVUl6+8JZXp651ThRc8+T124sAegg2eD8voHtXr 0d4nPkE3I506y3nU7uhwPmWlY0Q0lCnVQnsOnHXQbuACgCCD6NPjRpCNzrj536D4t4 Ft41bChjTc2krPkvw9E/7lW3RfXi804mPgQmhEJSFssI+jZ7buQ56fn0YzorFOf+AX DMCEc4tx6GOTg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id D133B180061 for ; Fri, 22 Mar 2024 17:39:00 +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.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,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 mail-lj1-f171.google.com (mail-lj1-f171.google.com [209.85.208.171]) (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 ; Fri, 22 Mar 2024 17:39:00 +0000 (UTC) Received: by mail-lj1-f171.google.com with SMTP id 38308e7fff4ca-2d68c6a4630so29926631fa.3 for ; Fri, 22 Mar 2024 10:38:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711129116; x=1711733916; darn=lists.php.net; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=wo+HPb1QUwUK336tlqwbCY2G9wamO/izKJ3CgI4Gxy4=; b=Ta3sTGuN7TTFGSYG1CBsKFBgb7dfQ1nqege6xIcn//ZuurCLFK+s4ZtQr+NAKgcA65 zlfZNP47EgIPNUkMuRo7gs27fSTWHuhBFmcdACGZfh0P6tUw379iRqNZOmZJOyymoBvT OyeWCdaazw+L06SVx4kzmbsXcfeRHTY/4AVvedeeMpo/rskY/sh+wVE/Ui9wfmYpcumc jvEqTXW9MEYKe90bPF4h4Io7OdJFvPoO06qwoCYr+hUFaGXZqp5FmtAIZR4bAmm9atQw kk6lKRzHPBAwEh8AxHM8cXFd6UA+8gfDgF798IdBx50efI0QFwtsrvkcUVOMiHaXGcvH kn8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711129116; x=1711733916; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=wo+HPb1QUwUK336tlqwbCY2G9wamO/izKJ3CgI4Gxy4=; b=f7ssRHZiIZcE2Dm6ZkrjH3GVasavuIw5NMu7mpHrVgb6IWlxG1GNtiUVJZTqTmb+Kw CbH/aLZ6kO8eVIaNhKWTbx0VZHqxY+RKnAd9Svjyn19kPecgNlPdvW4IjqYnUEUnq0oS 0hmm66pbkxAbQ9PxRxkgUPAqBcAVxBBPpXAaF43dvaEWx8aT4kAcvn4h0Hf7+afF1RxZ 0RlKbTCO+CuMGoCeSqKkQwDsHB9TjoiApdgCiEA9VF64WShYIGn6vWSABVcoaGjq6Cf7 0RO7xqGjv8jAKzaT3QV0ldQAyF8CJNS13z0uZ4QuWshLtlVWNuUxCxh3BmIK+kq1l3PU FBgQ== X-Gm-Message-State: AOJu0Yw4ipD7Igon3IMCbCeesBK6KNr8mhPDhO/vSx/U2Towb1K5uJoZ d18ubS+UFQpe/ZJg+D5N3rPgmNkuDLBttqpsCELVPhQbfx4cc8xqkQenbCeO X-Google-Smtp-Source: AGHT+IHSYtRVPM6QYQ3Au+47CXuTfmucQtOIqKzxKg6YCMHrQC6HDqlZwZMN6JzezGv0o8r0f3GJxw== X-Received: by 2002:ac2:546b:0:b0:513:e17d:cf41 with SMTP id e11-20020ac2546b000000b00513e17dcf41mr105754lfn.21.1711129115877; Fri, 22 Mar 2024 10:38:35 -0700 (PDT) Received: from smtpclient.apple ([89.249.45.14]) by smtp.gmail.com with ESMTPSA id c4-20020a170906170400b00a473abcb9fdsm49219eje.90.2024.03.22.10.38.35 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Mar 2024 10:38:35 -0700 (PDT) Message-ID: Content-Type: multipart/alternative; boundary="Apple-Mail=_A065FD35-CEA1-4258-A444-852CCB75FD0B" Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.400.31\)) Subject: Re: [PHP-DEV] Proposal: AS assertions Date: Fri, 22 Mar 2024 18:38:24 +0100 In-Reply-To: Cc: internals@lists.php.net To: "Rowan Tommins [IMSoP]" References: <3F78A125-1946-42E2-A4F5-A2B282BE2107@rwec.co.uk> <2d7ec203-6e80-445c-94f4-d29ef58743b1@rwec.co.uk> <7d53f2e4-46f3-46f1-89b0-6e1d3b0b2e32@app.fastmail.com> X-Mailer: Apple Mail (2.3774.400.31) From: claude.pache@gmail.com (Claude Pache) --Apple-Mail=_A065FD35-CEA1-4258-A444-852CCB75FD0B Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > Le 22 mars 2024 =C3=A0 16:18, Rowan Tommins [IMSoP] = a =C3=A9crit : >=20 > $optionalExpiryDateTime =3D $expiry as ?DateTimeInterface else = some_other_function($expiry); > assert($optionalExpiryDateTime is ?DateTimeInterface); // cannot fail, = already asserted by the "as" I think that the `is` operator is all we need; the `as` operator adds = syntax complexity for little gain. Compare: $optionalExpiryDateTime =3D $expiry as ?DateTimeInterface else = some_other_function($expiry); vs $optionalExpiryDateTime =3D $expiry is ?DateTimeInterface ? $expiry : = some_other_function($expiry); =E2=80=94Claude= --Apple-Mail=_A065FD35-CEA1-4258-A444-852CCB75FD0B Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8
Le 22 mars = 2024 =C3=A0 16:18, Rowan Tommins [IMSoP] <imsop.php@rwec.co.uk> a = =C3=A9crit :

$optionalExpiryDateTime =3D $expiry as = ?DateTimeInterface else some_other_function($expiry);
assert($optionalExpiryDateTime is = ?DateTimeInterface); // cannot fail, already asserted by the = "as"

I think that the `is` operator = is all we need; the `as` operator adds syntax complexity for little = gain. Compare:

$optionalExpiryDateTime =3D = $expiry as ?DateTimeInterface else = some_other_function($expiry);

vs
$optionalExpiryDateTime =3D $expiry is ?DateTimeInterface ? = $expiry : = some_other_function($expiry);

=E2=80=94Claude= --Apple-Mail=_A065FD35-CEA1-4258-A444-852CCB75FD0B--