Bug #81054 [Opn->Dup]: abs on string fatal error

From: Date: Wed, 19 May 2021 16:17:10 +0000
Subject: Bug #81054 [Opn->Dup]: abs on string fatal error
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-233900@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=81054&edit=1 ID: 81054 Updated by: cmb@php.net Reported by: alienmega at protonmail dot com Summary: abs on string fatal error -Status: Open +Status: Duplicate Type: Bug Package: *Math Functions Operating System: Windows PHP Version: 8.0.6 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: Duplicate of bug #80624. Previous Comments: ------------------------------------------------------------------------ [2021-05-19 15:58:22] alienmega at protonmail dot com Description: ------------ According to php.net abs ( mixed $number ) : int|float mixed is equivalent to the union type array|bool|callable|int|float |object|resource|string|null . Available as of PHP 8.0.0. So abs should take a string. Instead we get a fatal error Fatal error: Uncaught TypeError: abs(): Argument #1 ($num) must be of type int|float, string Test script: --------------- abs(''); Expected result: ---------------- 0 Actual result: -------------- Fatal error: Uncaught TypeError: abs(): Argument #1 ($num) must be of type int|float, string ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=81054&edit=1

« previous php.bugs (#233900) next »