link

# What’s new in PHP 8.2

I like this feature:

PHP 8.2 allows you to mark such “sensitive parameters” with an attribute, so that you don’t need to worry about them being listed in your stack traces when something goes wrong. Here’s an example from the RFC:

function login(
    string $user,
    #[\SensitiveParameter] string $password
) {
    // …
    throw new Exception('Error');
}
 login('root', 'root');
Fatal error: Uncaught Exception: Error in login.php:8
Stack trace:
#0 login.php(11): login('root', Object(SensitiveParameterValue))
#1 {main}
thrown in login.php on line 8

Leave a Reply

Your email address will not be published. Required fields are marked *