How can developers refactor the given code to adhere to PHP 8.2 standards and avoid deprecation warnings related to passing null to string parameters?

In PHP 8.2, passing null to string parameters will trigger deprecation warnings. To adhere to PHP 8.2 standards and avoid these warnings, developers should explicitly check for null values before passing them to string parameters. This can be achieved by using the null coalescing operator (??) to provide a default value if the variable is null.

// Original code
function printMessage(string $message) {
    echo $message;
}

// Refactored code to adhere to PHP 8.2 standards
function printMessage(?string $message) {
    echo $message ?? '';
}