[php-src] Issue #15107: Modifying the $value in a Property Hook setter alters the stack trace

From: Date: Thu, 25 Jul 2024 19:05:37 +0000
Subject: [php-src] Issue #15107: Modifying the $value in a Property Hook setter alters the stack trace
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-247374@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/15107 Author: petervanderwal ### Description The following code: ```php <?php class User { public string $name { set { // Normalize $value = trim(strtolower($value)); // Validate if ($value === '' || str_contains($value, ' ')) { throw new \InvalidArgumentException("Username can't be empty or contain spaces"); } // Set $this->name = $value; } } } $user = new User(); $user->name = 'JOHN DOE'; ``` Resulted in this output: ``` Uncaught InvalidArgumentException: Username can't be empty or contain spaces in file.php:13 Stack trace: #0 file.php(23): User->$name::set('john doe') // Stack trace displays value AFTER normalization WITHIN the setter hook ``` But I expected this output instead: ``` Stack trace: #0 file.php(23): User->$name::set('JOHN DOE') // Stack trace should display the value as passed to the setter to avoid confusions during debugging ``` ### PHP Version PHP 8.4.0alpha2 ### Operating System Docker image php:8.4.0alpha2-cli

« previous php.bugs (#247374) next »