Doc #80624 [Csd]: Undocumented change php 8 vs php 7 abs function

From: Date: Thu, 19 Aug 2021 11:36:30 +0000
Subject: Doc #80624 [Csd]: Undocumented change php 8 vs php 7 abs function
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-19087@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80624&edit=1

 ID:                 80624
 Updated by:         cmb@php.net
 Reported by:        ilyes dot ahidar at gmail dot com
 Summary:            Undocumented change php 8 vs php 7 abs function
 Status:             Closed
 Type:               Documentation Problem
 Package:            *Math Functions
 Operating System:   Linux Fedora 33
 PHP Version:        8.0.1
 Assigned To:        cmb
 Block user comment: N
 Private report:     N

 New Comment:

See <https://github.com/php/doc-en/commit/6c7c7edf76fd09ac0e91ed702727bccf32e548e4>.


Previous Comments:
------------------------------------------------------------------------
[2021-08-18 16:35:33] kawewong at gmail dot com

This also is not in these pages

https://www.php.net/manual/en/migration80.incompatible.php
https://www.php.net/manual/en/migration80.deprecated.php
https://www.php.net/manual/en/migration80.other-changes.php

I could not find info about this and just let my php run until one day there are unknown errors and
I find out that it is incompatible.

<?php
$num = '1.00';
var_dump(abs($num));// working fine until PHP 8.0+
?>

Maybe please update any one of these page.

------------------------------------------------------------------------
[2021-05-23 11:27:57] cmb@php.net

Fixed as <https://github.com/php/doc-en/commit/e2a460ca39fece49eefdd5bd2282e5ba7b488fea>.

------------------------------------------------------------------------
[2021-05-19 16:17:10] cmb@php.net

Related To: Bug #81054

------------------------------------------------------------------------
[2021-01-14 16:54:27] 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-14 16:21:37] 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


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=80624&edit=1


Thread (11 messages)

« previous php.doc.bugs (#19087) next »