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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
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-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 08:01:28 2024 UTC