Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129735 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 lists.php.net (Postfix) with ESMTPS id CD0841A00BC for ; Mon, 5 Jan 2026 18:56:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1767639420; bh=oIDKtzb4LJOLlJBJEshjb0Z36699nlA7SEkXqU7esAA=; h=Date:Subject:To:References:From:In-Reply-To:From; b=ihb3qYhL0Gf8a2ocwJEaLIUskqXx3/MXMbioAV6py55F5tXAE8W0pWlIAitSSCeOF tEHb+zlZjd8GhJKWNV6uhw+szDgOPwcFOaxM0l9n09pWXzYWuYhNE2z7toh9C43RDQ LYo7+xzy/sTfLi9okf4+ZTZ7Z5LeNDg9BgCrKs3767hwcYCUauZ5TAY6PBJ0IDHLFs OCnuzTOf5uxleiPOXDyplT/ilqobu7dZfStEu2eFQG9Iyko7hIVwpCgD8sEC8/VBTH JJhsVi7X1TMsvEH81ugmqrV4Qj5FvX0BMTz/Zaf/knO95nfH1u2WCD38ul+gzspLYV IUfonCVQrYDUQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 7BFF81801E3 for ; Mon, 5 Jan 2026 18:56:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) 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 autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.47]) (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 ; Mon, 5 Jan 2026 18:56:59 +0000 (UTC) Received: by mail-ej1-f47.google.com with SMTP id a640c23a62f3a-b79ea617f55so51902466b.3 for ; Mon, 05 Jan 2026 10:56:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767639413; x=1768244213; darn=lists.php.net; h=in-reply-to:from:content-language:references:to:subject:user-agent :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to; bh=9BX9TbvZLqh2yxR97lm5ls4mymAU45dQevqmelklk4w=; b=EaOukg0ry4v8FcUIxdZJMKO/pQmJhYqLrCxPetWR4e1D+ya4R4S3pexPhppvVjQE1W T9rJXLh+gabUr79QN+ByAMlLUVGAC+qVPaVcZXx6BMzXR3XeJGg1uz5WGlL79zeYxFkA qZzb2MMFoVkhKtWTYqx7rBFBE0r5GZAqPQCIHtuMdW2+Gtjco5ld4vox5NMLvp8IN5mF +lEvvrZKaeI2LTpRzY7EJCXNdPBHQNKBu693v73O8MAkw8NNmW0AREhvACqX4rzNpquD fB6lBgzAzqAhAXZ5Cj01C7cpb9QfXWo7gZujqrMwoiNYUBWtXgsTIjps42QYxJY9h4pn vEYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767639413; x=1768244213; h=in-reply-to:from:content-language:references:to:subject:user-agent :mime-version:date:message-id:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9BX9TbvZLqh2yxR97lm5ls4mymAU45dQevqmelklk4w=; b=E6Ji2mNTf4n3RJIR4TEIVbEM1AP9P+07X6nAnwRysxw6rfyEYjxrPEW3WZ6f+ZVPal IIsP/KHH1VoAsCQNjp1wDbPdVctxj9aavkeI0ckQmbcRmiTeTF8zvZLYnPvltr9t88gp Jop1ryuUM6hTxRo73quJRmFlQn/AtYIBZEUGwuf4vhmUBhxDNW9+hHxPsdWiSP0R9ur+ PN8LvrRBZat3LnTAxwf8xp4mUA4Qlq7wjRQZ7sQWgUnOB7fZM46HuXdnp8CiT4QC1o+S SJeYRd6S1YtqQnDfZAxQJPk/0HUKmrPSJrWvza0qZQzwmEOXCPRAgNSCwpd9Xg+7JD14 CgYA== X-Forwarded-Encrypted: i=1; AJvYcCWLh2Hl3Se12qhOXTwH3xBHAa/7lh6310q0KlH7vBJh1qRETAEJh8qJpkuexk3C3vcwSNcPpNWLBGI=@lists.php.net X-Gm-Message-State: AOJu0Yw08Z1onWUnm9+sBeJbbuglqgr7aVC4dfNpeLQly76YwMr0dua1 VCwKidffvkBQ5wFE2BDjNwF5GtNbPByRqrq0IvgijiyZWl0wYNwsxkN0 X-Gm-Gg: AY/fxX4NOpglyS08VGGz+05AvY2NnNh20zdKZKABA1IWl47SLOkqOn4uHZkvwnG68D7 1MgJ/h6DB3GVU7lJrKJ06G/wqbfXSJn2l3m+ZUyNaGF9lpLbXOGdgc2DZMVQs79zm+edJEl/PgR oz1KbGNBQKtVAG1oJ+PLMsV0y4J3d3oNe80iEGRCQkaz/p7/ypQRST0KJdMRsMq7mkY1rYNICtj cK52pVhoY56Obt8MT1b18wEGHSgrIYQH4kgyTmVk+6qL3x0ZsijoJdK+n0AMnoU2beMDiAbkGnY OGAN7cVcZLly8LtVnPCEC5TBZ312DXEcQd6mL2dfg0C3ea9AUHErF5Z5aOYwMkRufhXq/bJaTdU 74+YyXalkL0v5K+DzFPNavsGzQXyueCsdYTNhpu8mMh+cEQCMrHqZrOdnNTPXwHR9RFwfAMgngd bprJfXE1U4qImVlpYTWYZqHmc= X-Google-Smtp-Source: AGHT+IE2g8c+E01AYi9RonFO1eFhEHxI0voM57o4DcrQtqkx/dTiOxxcJFU/ufCNickS7e2+CeUZyQ== X-Received: by 2002:a17:906:7315:b0:b83:246c:93ab with SMTP id a640c23a62f3a-b8426a67da8mr76130866b.24.1767639412509; Mon, 05 Jan 2026 10:56:52 -0800 (PST) Received: from [192.168.1.16] ([46.181.226.137]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b842a5641casm1700066b.64.2026.01.05.10.56.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 05 Jan 2026 10:56:52 -0800 (PST) Content-Type: multipart/alternative; boundary="------------lmpB9JxmeJV7tHRxKKXrp2LA" Message-ID: Date: Tue, 6 Jan 2026 01:56:50 +0700 Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PHP-DEV] [RFC] Nullable and non-nullable cast operators To: Alexandre Daubois , PHP internals list References: Content-Language: en-US In-Reply-To: From: vadim.dvorovenko@gmail.com (Vadim Dvorovenko) This is a multi-part message in MIME format. --------------lmpB9JxmeJV7tHRxKKXrp2LA Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit > Nicolas Grekas and I would like to propose this new RFC to the > discussion. This proposes to introduce two new cast operators to the > language: `(?type)` and `(!type)`. > > Please find the details here: > https://wiki.php.net/rfc/nullable-not-nullable-cast-operator Hi, Alexandre. I was just starting to think about writing such RFC, and you already did it )) As for me, now is good time to return to idea of such operators. I really needed it some days ago )) The idea is not new, here is https://wiki.php.net/rfc/nullable-casting previous simular RFC, but you did not refer it in your RFC. Please list it in you references. Previous RFC described settype function behavior changes. Please describe it (as well as not changing, if you prefer). But your RFC brings two ideas, of (?type) and (!type) operator. I think, it's not good idea to discuss and bring them together. (?type) * the idea came up a long time ago and by several independent people (see previous rfc). * "spelling" of the type corresponds to the "spelling" of the types of parameters and results of functions and class properties * such operator is just syntax sugar and could be transpiled to simple ternary operator (if php was js ))) ) * discussion about that operator could be same level as about ?? or ??= operators (!type) * This is a relatively new idea * the "spelling" can be interpreted ambiguously, ! is widely used as boolean NOT, and currently in php never as strictness. Here can be separate discussion about best symbol to such semantics * it correlates with strict_types option, can throw new error type and can not be considered syntax sugar * there can be much more discussion about exception type to throw (see Larry's Garfield message) * to reduce cohesion with strict_types directive, we may introduce as new declare(strict_casts=1) directive. That's subject of discussion too May be it would be better to separate RFC for two different features. It will simplify discussions. --------------lmpB9JxmeJV7tHRxKKXrp2LA Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
Nicolas Grekas and I would like to propose this new RFC to the
discussion. This proposes to introduce two new cast operators to the
language: `(?type)` and `(!type)`.

Please find the details here:
https://wiki.php.net/rfc/nullable-not-nullable-cast-operator

Hi, Alexandre.
I was just starting to think about writing such RFC, and you already did it )) As for me, now is good time to return to idea of such operators. I really needed it some days ago ))

The idea is not new, here is https://wiki.php.net/rfc/nullable-casting previous simular RFC, but you did not refer it in your RFC. Please list it in you references.

Previous RFC described settype function behavior changes. Please describe it (as well as not changing, if you prefer).

But your RFC brings two ideas, of (?type) and (!type) operator. I think, it's not good idea to discuss and bring them together.

(?type)

  • the idea came up a long time ago and by several independent people (see previous rfc).
  • "spelling" of the type corresponds to the "spelling" of the types of parameters and results of functions and class properties
  • such operator is just syntax sugar and could be transpiled to simple ternary operator (if php was js ))) )
  • discussion about that operator could be same level as about ?? or ??= operators

(!type)

  • This is a relatively new idea
  • the "spelling" can be interpreted ambiguously, ! is widely used as boolean NOT, and currently in php never as strictness. Here can be separate discussion about best symbol to such semantics
  • it correlates with strict_types option, can throw new error type and can not be considered syntax sugar
  • there can be much more discussion about exception type to throw (see Larry's Garfield message)
  • to reduce cohesion with strict_types directive, we may introduce as new declare(strict_casts=1) directive. That's subject of discussion too

May be it would be better to separate RFC for two different features. It will simplify discussions.

--------------lmpB9JxmeJV7tHRxKKXrp2LA--