Bug #81398 [NEW]: Comparing int/string with max() always returns string

From: Date: Sun, 29 Aug 2021 21:57:10 +0000
Subject: Bug #81398 [NEW]: Comparing int/string with max() always returns string
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-236161@lists.php.net to get a copy of this message
From: php at ober-mail dot de Operating system: Debian 10 PHP version: 8.0.10 Package: *Math Functions Bug Type: Bug Bug description:Comparing int/string with max() always returns string Description: ------------ The documentation of max() says: "Values of different types will be compared using the standard comparison rules. For instance, a non-numeric string will be compared to an int as though it were 0." Using PHP 8.0 and above, I'm observing a deviating behavior, that is, the string value is returned instead. Parameter order does not matter. If this is the intended behavior, the documentation should be updated / the cited snippet should be removed. Up to PHP 7.4.13, the observed result matches the documentation. Test script: --------------- <?php var_dump(max("A", PHP_INT_MAX)); var_dump(max(PHP_INT_MAX, "A")); Expected result: ---------------- int(1) int(1) Actual result: -------------- string(1) "A" string(1) "A" -- Edit bug report at https://bugs.php.net/bug.php?id=81398&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=81398&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=81398&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=81398&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=81398&r=needscript Try newer version: https://bugs.php.net/fix.php?id=81398&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=81398&r=support Expected behavior: https://bugs.php.net/fix.php?id=81398&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=81398&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=81398&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=81398&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=81398&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=81398&r=dst IIS Stability: https://bugs.php.net/fix.php?id=81398&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=81398&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=81398&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=81398&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=81398&r=mysqlcfg

« previous php.bugs (#236161) next »