| Newsgroups |
php.standards |
| Message-ID |
<[email protected]> |
Edit report at https://bugs.php.net/bug.php?id=79061&edit=1
ID: 79061
Comment by: [email protected]
Reported by: karolis dot bartkus at gmail dot com
Summary: Nullable type casting
Status: Assigned
Type: Feature/Change Request
Package: PHP Language Specification
PHP Version: 8
Assigned To: geekcom
Block user comment: N
Private report: N
New Comment:
Hi Karolis,
Send an e-mail to [email protected] to measure reaction to your intended proposal. State who would implement the feature, or whether the proposal is only a “concept”. Proceed with an RFC if feedback is not negative or if a detailed RFC will clarify the proposal. Mail list subscription is at http://php.net/mailing-lists.php. (Reminder: always "bottom post" your replies. Never “top post”.)
For detailed RFC Process instructions please see:
https://wiki.php.net/rfc/howto
Previous Comments:
------------------------------------------------------------------------
[2020-01-03 14:08:35] karolis dot bartkus at gmail dot com
Description:
------------
Currently the type casts allowed are: (int), (bool), (string), etc. It would be very convenient to have their nullable counterparts, i.e.: (?int), (?bool), (?string), etc.
Generally speaking the idea is to be able to do this:
$nullable_int = (?int) $nullable_string;
which would be an equivalent of this:
$nullable_int = is_null($nullable_string) ? null : (int) $nullable_string;
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=79061&edit=1