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 Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
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

Pull Requests

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-2024 The PHP Group
All rights reserved.
Last updated: Fri Oct 04 18:01:29 2024 UTC