php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #80624 Undocumented change php 8 vs php 7 abs function
Submitted: 2021-01-14 16:21 UTC Modified: 2021-01-14 16:53 UTC
From: ilyes dot ahidar at gmail dot com Assigned:
Status: Verified Package: *Math Functions
PHP Version: 8.0.1 OS: Linux Fedora 33
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2021-01-14 16:21 UTC] ilyes dot ahidar at gmail dot com
Description:
------------
---
From manual page: https://php.net/function.abs
---

The manual says that the abs() function accepts 1 argument of the type "mixed", but enabling strict_types and passing a string to the abs function outputs an type error.

Test script:
---------------
<?php

declare(strict_types=1);

$a = "0.00";

var_dump(abs($a));

Expected result:
----------------
In php 7 it would output:

float(0)

Actual result:
--------------
Fatal error: Uncaught TypeError: abs(): Argument #1 ($num) must be of type int|float, string given in /in/ZD7Kd:7
Stack trace:
#0 /in/ZD7Kd(7): abs('0.00')
#1 {main}
  thrown in /in/ZD7Kd on line 7

Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-01-14 16:53 UTC] cmb@php.net
-Status: Open +Status: Verified
 [2021-01-14 16:54 UTC] cmb@php.net
The following pull request has been associated:

Patch Name: Generate some standard methodsynopses based on stubs
On GitHub:  https://github.com/php/doc-en/pull/289
Patch:      https://github.com/php/doc-en/pull/289.patch
 [2021-01-25 10:27 UTC] donaldmontgo82 at gmail dot com
Thanks for Sharing....

https://www.imessageapp.biz/
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue Mar 02 09:01:24 2021 UTC