modify submit on user login so that only admins can log in through this route
You are getting this because you did not include the use statement at the top of your file:

use Drupal\Core\Form\FormStateInterface;

function xxx_form_alter(&amp;$form, FormStateInterface $form_state, $form_id) {

 if ($form_id=='user_login_form') {

    $form['actions']['submit']['#submit'][] = 'xxx_form_submit';
  }
}


You can use the full path, but it is preferred for developers to do use statements.