PHP errors after update to php 8.1 from 7.4

Aftere update my website in wordpress is updated to php 8.1 i reveive 2 errors om wp-admin login page:

Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in wp-includes/formatting.php on line 5397

Where this code is located:

function wp_strip_all_tags( $string, $remove_breaks = false ) {
    $string = preg_replace( '@<(script|style)[^>]*?>.*?</\1>@si', '', $string );
    $string = strip_tags( $string );

    if ( $remove_breaks ) {
        $string = preg_replace( '/[rnt ]+/', ' ', $string );
    }

    return trim( $string );
}

and this message:

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in wp-includes/pluggable.php on line 598

where this code is located:

function wp_authenticate( $username, $password ) {
        $username = sanitize_user( $username );
        $password = trim( $password );

I didn’t get what is wrong here. Can somebody help me?

I have tried to make litle changes to the code but i only receive more errors.