This error occured when upgrading to PHP 8 in a Drupal 9 installation:

strlen(): Passing null to parameter #1 ($string) of type string is deprecated 

Solution

From:

$search = \Drupal::request()->query->get('search');

if(strlen($search) > 0) {
  ....
}
    

To:

    $search = \Drupal::request()->query->get('search');
    if($search) {
      if(strlen($search) > 0) {
       ....
      }
    }