php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81054 abs on string fatal error
Submitted: 2021-05-19 15:58 UTC Modified: 2021-05-19 16:17 UTC
From: alienmega at protonmail dot com Assigned: cmb (profile)
Status: Duplicate Package: *Math Functions
PHP Version: 8.0.6 OS: Windows
Private report: No CVE-ID: None
 [2021-05-19 15:58 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-05-19 16:17 UTC] cmb@php.net
-Status: Open +Status: Duplicate -Assigned To: +Assigned To: cmb
 [2021-05-19 16:17 UTC] cmb@php.net
Duplicate of bug #80624.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Aug 02 07:01:23 2021 UTC