Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127941 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 599E51A00CD for ; Mon, 7 Jul 2025 16:47:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1751906745; bh=gCqu7LXkZxxtLzxTW6t1wbh1swQjnmm7xF72H/Bdjqw=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Ci8zAAKoeP+qZbMMfxUiUMldZfo95A5E9FKXlGzfstLdnZiNJv8OQpiUzZHrvh/61 v9wvsZ5ZDRl658WJjkgoUP2WhIzo8A7OoaN8zjme+ZHzl7317q4zKv/xoogGVc/kpB VISu7uDfhWe/g3LSZUqLiSGoCYStsUV1gnoSlp1BvnWxOf3lMQlcT86ILzVe1PeKVn vlae0Xwny4WfEWxBM1NOwAdvqxzsZ3LtPlWx4CmaRsxcmGJJhWLC5KlQY1zMn+HOQV 9cXP+p0AGhv8l2KXw6sBTzd8769W1OeoFZzP0HzAeKSMUr6u67fImKgXs67x0xzEXZ gYHfoqgpM+wYA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 7A2A61805DB for ; Mon, 7 Jul 2025 16:45:43 +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.4 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: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from mail-yw1-f179.google.com (mail-yw1-f179.google.com [209.85.128.179]) (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, 7 Jul 2025 16:45:41 +0000 (UTC) Received: by mail-yw1-f179.google.com with SMTP id 00721157ae682-714067ecea3so23952487b3.0 for ; Mon, 07 Jul 2025 09:47:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1751906852; x=1752511652; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=gCqu7LXkZxxtLzxTW6t1wbh1swQjnmm7xF72H/Bdjqw=; b=jacPcyDKdJEV4zx1CEmVY6gsvDjTGyaB9FPraopSXy4KYkUA1jDd46TqHMZUz2KPKe j8CAbQC0kND1mAPjgEwTlY3WNLYHoMKi6No78kSGfMGqlXoaulcozXPUf9+IxM0CNaux W4aqXqOL38u6cM/BIt+pj1sTCX5WoaNUShe8J/158GRQboY5BkKcs6oRWD6qUHiDplsc AuA9XPeK2CIAONP74w2t3Lm8BqiX4EwoOtEMl0zWhwQydDVM2B/twUcVZDFWJCLOZCAI PPaVOSofPbUFJYzUM/nnUAHeXd+qDyaWiegAU7XfDEloqPzgJMbiBUS1Rl0HA8rH5mXA 55Yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751906852; x=1752511652; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=gCqu7LXkZxxtLzxTW6t1wbh1swQjnmm7xF72H/Bdjqw=; b=iec7/vfNntXEXx671l/kvRNZQHmteSnul2NyrvpkRNOG26gAEFLXkDpNRzCv9+DdbT 46qQPAUR4YgAcqsZAPDhT2PP8ak0mJyzfqU/VL7cjPkgVawTe5Z8e9Tt22I1yjCph1R1 YSD6JWWkphBtGUVUcUdbOin/p6+zpV54FmEhZA6MNjhqBql6Ku82p3+NL3QDvS3NebxW NIKwxbVMXIAtkJTwOalN2smfq265QbeiBy3uk/2ieEKmZ6IyApkNRyZU1ZReL4Zb0Ys/ hovIvbqqJEDSPsBHd6xMyODMJ2fUBZRv8QEW7t2Pu0zA0jxCz0Q1XYfTBSqZrc0IQ4oh 5gLg== X-Gm-Message-State: AOJu0Yw6ULbLD9BxSCNg/f8fs6g2FZBquJ7zcs1fPAmk7AXRQGwZNpWo r/ZzOKtzdrzUyccrHXpy6bl6gvYLKKHNQGr/wn3Ew7VoAeRj+xNWSx9raS9OKmc69VKYgFa2Yst S44si8Al2AbtNbWgooxjXBdScjzS/564= X-Gm-Gg: ASbGncshVCvPknjJgggsiUDJP7oD3Z1JPzLQBRfP/12Jl2KY7llqJb26JaRUTJTzmv7 pc2Qov9bfCkOQYF7IDcrm9F+ybyuqqbzgwMPvXmV4ehKlamP2UUU/S8O57Seuo8ED9h3YueAe3e IsnT25smT/HxJrgMo8LPsPo4hGJZi+02rSiCXdadn1f9U= X-Google-Smtp-Source: AGHT+IEW3+KTVGBJlkogc7QVME/S+4yUmkFGQGdlFzaezSFkijYJOYrU8aB5059b+J4baXOqhoaIjrTJA/AKUIa0o5g= X-Received: by 2002:a05:690c:9681:b0:710:d81a:b345 with SMTP id 00721157ae682-7166b69a408mr158511357b3.29.1751906851615; Mon, 07 Jul 2025 09:47:31 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: <9f14ae52-6c78-41a1-8d2a-7330fd92d1a9@app.fastmail.com> In-Reply-To: <9f14ae52-6c78-41a1-8d2a-7330fd92d1a9@app.fastmail.com> Date: Mon, 7 Jul 2025 19:47:14 +0300 X-Gm-Features: Ac12FXzOkvw2XwEFimXuOY2pmVSl3x3kDPBOj5kzl74wto6J9lhLJbPTWCrmQd4 Message-ID: Subject: Re: [PHP-DEV] [Discussion][RFC Idea] Cast Variables by Reference To: joseph+php@josephleedy.dev Cc: PHP Internals Content-Type: multipart/alternative; boundary="00000000000091f8510639599933" From: drealecs@gmail.com (=?UTF-8?Q?Alexandru_P=C4=83tr=C4=83nescu?=) --00000000000091f8510639599933 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Jul 7, 2025 at 7:25=E2=80=AFPM Joseph Leedy wrote: > > As a developer, I would like to have variables of one type cast to anothe= r > type automatically so that I do not need to assign the variable to itself= . > > > What if we could do this instead? > > ```php > $price =3D '5.0123'; > ... > (float) $price; > > var_dump($price); // Result: `float: 5.0123` > ``` > > This is valid code now, and does not perform the cast. You need to use a slightly different syntax, maybe `(float)&$price;` that is an error now. --=20 Alex --00000000000091f8510639599933 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

On Mon, Jul 7, 2025= at 7:25=E2=80=AFPM Joseph Leedy <joseph+php@josephleedy.dev> wrote:

As a developer, I would like to have variables of one type cast to another =
type automatically so that I do not need to assign the variable to itself.<= br>

What if we could do this instead?

```php
$price =3D '5.0123';
...
(float) $price;

var_dump($price); // Result: `float: 5.0123`
```


This is valid code now, and doe= s not perform the cast.
You need to use a slightly different synt= ax, maybe `(float)&$price;` that is an error now.

<= div>--=C2=A0
Alex
--00000000000091f8510639599933--