[Discussion][RFC Idea] Cast Variables by Reference
| From: | Joseph Leedy | Date: | Mon, 07 Jul 2025 16:22:20 +0000 |
| Subject: | [Discussion][RFC Idea] Cast Variables by Reference | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-127938@lists.php.net to get a copy of this message | ||
Hello, I'm Joseph, or Seph for short. I'm a long time listener, but a
first-time caller. I've had an idea rattling around in my noggin for a while
that I'd like your feedback on:
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.
Instead of the following:
```php
$price = '5.0123';
...
$price = (float) $price;
var_dump($price); // Result:
float: 5.0123
```
What if we could do this instead?
```php
$price = '5.0123';
...
(float) $price;
var_dump($price); // Result: float: 5.0123
```
If everyone thinks this a good idea, I would be willing to put together an
RFC and work on the implementation myself, with guidance from an experienced
core developer. I have no experience with C/C++, other than a brief foray
more than twenty years ago, but I am willing to learn.
Thank you for your consideration! Also, a huge thank you to everyone who
has made PHP what it is today!
(**Note**: No AI was used in the writing of this message.)