[PHP-BUG] Req #79061 [NEW]: Nullable type casting

[email protected] ("karolis dot bartkus at gmail dot com") Fri, 03 Jan 2020 14:08:35 +0000
Newsgroups php.standards
Message-ID <[email protected]>
From:             karolis dot bartkus at gmail dot com
Operating system: 
PHP version:      Next Major Version
Package:          PHP Language Specification
Bug Type:         Feature/Change Request
Bug description:Nullable type casting

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 bug report at https://bugs.php.net/bug.php?id=79061&edit=1
-- 
Fix committed:                    https://bugs.php.net/fix.php?id=79061&r=fixed
Fixed in release:                 https://bugs.php.net/fix.php?id=79061&r=alreadyfixed
Need backtrace:                   https://bugs.php.net/fix.php?id=79061&r=needtrace
Need Reproduce Script:            https://bugs.php.net/fix.php?id=79061&r=needscript
Try newer version:                https://bugs.php.net/fix.php?id=79061&r=oldversion
Not developer issue:              https://bugs.php.net/fix.php?id=79061&r=support
Expected behavior:                https://bugs.php.net/fix.php?id=79061&r=notwrong
Not enough info:                  https://bugs.php.net/fix.php?id=79061&r=notenoughinfo
Submitted twice:                  https://bugs.php.net/fix.php?id=79061&r=submittedtwice
register_globals:                 https://bugs.php.net/fix.php?id=79061&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=79061&r=phptooold
Daylight Savings:                 https://bugs.php.net/fix.php?id=79061&r=dst
IIS Stability:                    https://bugs.php.net/fix.php?id=79061&r=isapi
Install GNU Sed:                  https://bugs.php.net/fix.php?id=79061&r=gnused
Floating point limitations:       https://bugs.php.net/fix.php?id=79061&r=float
No Zend Extensions:               https://bugs.php.net/fix.php?id=79061&r=nozend
MySQL Configuration Error:        https://bugs.php.net/fix.php?id=79061&r=mysqlcfg