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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: alienmega at protonmail dot com
New email:
PHP Version: OS:

 

 [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