Req #67837 [Opn->Sus]: Allow cast to (number)

From: Date: Mon, 01 Oct 2018 12:17:05 +0000
Subject: Req #67837 [Opn->Sus]: Allow cast to (number)
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-217339@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=67837&edit=1 ID: 67837 Updated by: cmb@php.net Reported by: lkmorlan at uwaterloo dot ca Summary: Allow cast to (number) -Status: Open +Status: Suspended Type: Feature/Change Request -Package: Variables related +Package: Scripting Engine problem Operating System: all PHP Version: 5.6.0RC3 Block user comment: N Private report: N New Comment: A former RFC[1] reserved the word “numeric”, so it would be more reasonable to use this instead of “number”. However, I feel that a type cast which is not also allowed as type declaration is somewhat strange. Anyhow, this feature request certainly requires discussion on internals@ and likely the RFC process[2]. Feel free to start it. For the time being, I'm suspending this ticket. [1] <https://wiki.php.net/rfc/reserve_even_more_types_in_php_7> [2] <https://wiki.php.net/rfc/howto> Previous Comments: ------------------------------------------------------------------------ [2018-09-09 00:52:23] carusogabriel@php.net A number cast would be useful to convert, for example, binary bases, which today isn't possible using +, (int) or (float) before the variable: https://3v4l.org/kspcM ------------------------------------------------------------------------ [2014-08-14 05:49:38] datibbaw@php.net Alternatively, you can currently accomplish this with a unary +: $number = +$var; ------------------------------------------------------------------------ [2014-08-13 18:52:22] lkmorlan at uwaterloo dot ca Description: ------------ It would be useful to have the ability to cast to (number), which would cast to either (int) or (float), as needed. (number) $var; Would be the same as: $var += 0; ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=67837&edit=1

« previous php.bugs (#217339) next »