Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118757 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 60231 invoked from network); 5 Oct 2022 17:53:23 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 5 Oct 2022 17:53:23 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 1180618053F for ; Wed, 5 Oct 2022 10:53:23 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-yw1-f169.google.com (mail-yw1-f169.google.com [209.85.128.169]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 5 Oct 2022 10:53:22 -0700 (PDT) Received: by mail-yw1-f169.google.com with SMTP id 00721157ae682-349c4310cf7so170253077b3.3 for ; Wed, 05 Oct 2022 10:53:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=n3rILHBNQ37jbcELeAZMPPej4eMQUDu1pJxTAVF9jDs=; b=HqWg5xkAICqylw3wDPi2FAvVJKHQQBAjTMCnyCf0FFZJc/sTIiL62/cHmfjL9s8D9A PBC16Ald6NVRM2trusGIN0+wKXila2XKFrSfe/LT67f9ZNrCL1h8GYf2gGx+anOTFPr/ fW9O9ihJbOleM/mQDht58TwEOKMbbyTB4jiVUpzDNj/fbLuDPhv6UY4GR1G2UgZXXkgs IRzr0Vb+E0ltsUDeSDSsSD+AajPOQcOVvMnOcLJPTkX1Aqivg+YlI6qUKU9p4EGRkEQC njGgcHPMVQRoFpYJHJ5+eM4yqs4MPV+X8LIGVa1KTJHl3nq52E00gJpslguWZ+zachQh gyWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=n3rILHBNQ37jbcELeAZMPPej4eMQUDu1pJxTAVF9jDs=; b=N3FnynYBJDJqmEKZ/t8galbWAJO2AcMCyXgRl1wZ810Vvqn3GvpXIFBpPzHIJvVhKQ Bymg0IItCYahnusV1qIFF4Sc9Q72txr2y1FzBHU8IlKpMaZwBVmjPZGRuLI7fLEcMoDI CZpKEI6iFZYSUvePjd34F2vg4+Ixh3Q4x0aKdFlb72/+jglUuh6CCA8a6lAOoZcntwYK 8rnNPb9oP9Hy0yoODHE7rXubCAi8Xy5TS/JmJVpSaCUcHPhmtgD0Z5hpeB+6N794EL2Y a/mRh21wAI2tTucd66eUoFevgaiBXAAtYcoSwtaI/23y0SsvcfD6WOYJTivd/lg3+f/i jYoQ== X-Gm-Message-State: ACrzQf0/zlqlLdLhPxDHOCrkG81w1YFn3fWYNM301RyCVBtE6DuWH7Tu SXLlf445B8zs9obHYQ+9ChcN+0YbaEYw0BkLXjI= X-Google-Smtp-Source: AMsMyM6GTCQvB0kUQJodV+8gPchEbBYtfWKhf/7rGtftj14W0vqwFDR0lNxd4TEiLXWze6VTYjDEhvRh2LJ8iZHinSQ= X-Received: by 2002:a81:e11:0:b0:355:de44:f4d5 with SMTP id 17-20020a810e11000000b00355de44f4d5mr872316ywo.215.1664992402161; Wed, 05 Oct 2022 10:53:22 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 5 Oct 2022 20:53:11 +0300 Message-ID: To: juan carlos morales Cc: Claude Pache , PHP Internals Content-Type: multipart/alternative; boundary="000000000000af45f905ea4d4074" Subject: Re: [PHP-DEV] Union type casts From: zsidelnik@gmail.com (Eugene Sidelnyk) --000000000000af45f905ea4d4074 Content-Type: text/plain; charset="UTF-8" I used to have an awkward feeling when it was necessary to convert the nullable integer into a nullable string. It would be kind of ternary operator anyway. Either `$b = (null !== $a) ? (string)$a : null;` or `$b = (string)$a ?: null;`. A lot easier to read would it be if written this way: `$b = (?string)$a;`. The intentions are clear when doing explicit type-cast. Currently, I don't see any other situations when this feature may be useful Thank you On Wed, Oct 5, 2022, 4:43 PM juan carlos morales wrote: > There is a difference is declaring a function parameter of different > types ... because before hand, when the code calls the function, we > might not be sure about what kind if data the function will receive, > so the function could expect different types, and work the parameter > correctly internally..... nice > > > but ... when casting, on purpose, what use case can apply to it? > > Are you facing a situation where manual union type cast is needed? can > you share it with us? > > thanks > --000000000000af45f905ea4d4074--