Req #67837 [Sus]: Allow "numeric" type cast and declaration

From: Date: Tue, 20 Nov 2018 19:59:25 +0000
Subject: Req #67837 [Sus]: Allow "numeric" type cast and declaration
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-218065@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 User updated by: lkmorlan at uwaterloo dot ca Reported by: lkmorlan at uwaterloo dot ca -Summary: Allow cast to (number) +Summary: Allow "numeric" type cast and declaration Status: Suspended Type: Feature/Change Request Package: Scripting Engine problem Operating System: all -PHP Version: 5.6.0RC3 +PHP Version: 7.x Block user comment: N Private report: N New Comment: I'm fine with "numeric" and I agree about the declaration. Previous Comments: ------------------------------------------------------------------------ [2018-10-01 12:17:05] cmb@php.net 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> ------------------------------------------------------------------------ [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 (#218065) next »