Bug #81306 [NEW]: PHP doesn't fully evaluate new expressions passed in named arguments

From: Date: Wed, 28 Jul 2021 20:35:26 +0000
Subject: Bug #81306 [NEW]: PHP doesn't fully evaluate new expressions passed in named arguments
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-235443@lists.php.net to get a copy of this message
From: raincomplain at outlook dot com Operating system: PHP version: 8.1.0beta1 Package: Scripting Engine problem Bug Type: Bug Bug description:PHP doesn't fully evaluate new expressions passed in named arguments Description: ------------ According to the RFC of "New in initializers": Parameter default values are evaluated from left to right on every call to the function where the parameter is not explicitly passed. So calling a method by not explicitly passing a default paramater and using named arguments to call other arguments should trigger default parameter evaluation, so far so good. However, if both arguments are objects of the same class that modify a static property, PHP only returns the copy of the default object and "overlooks" the other object that was passed as a named argument. Test script: --------------- class A { public static int $x = 0; public function __construct(int $x) { self::$x = $x; // changing this to self::$x += $x; works as expected } } function getTest(A $o1 = new A(88), A $o2 = new A(77)) { return A::$x; } var_dump(getTest(o2: new A(55))) Expected result: ---------------- int(55) Actual result: -------------- int(88) -- Edit bug report at https://bugs.php.net/bug.php?id=81306&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=81306&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=81306&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=81306&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=81306&r=needscript Try newer version: https://bugs.php.net/fix.php?id=81306&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=81306&r=support Expected behavior: https://bugs.php.net/fix.php?id=81306&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=81306&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=81306&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=81306&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=81306&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=81306&r=dst IIS Stability: https://bugs.php.net/fix.php?id=81306&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=81306&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=81306&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=81306&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=81306&r=mysqlcfg

« previous php.bugs (#235443) next »