I have written a hook form alter which adds a submit action but I get this error
Recoverable fatal error: Argument 2 passed to xxx_form_submit() must be an instance of FormStateInterface, instance of Drupal\Core\Form\FormState given in xxx_form_submit()
the code is like this
function xxx_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
if ($form_id=='user_login_form') {
$form['actions']['submit']['#submit'][] = 'xxx_form_submit';
}
}
function xxx_form_submit ($form, FormStateInterface $form_state) {
$username=$form_state->getValue('name'));
}