Fail if validate hander or submit handler does not exist

Chiusa
#603 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
drupal, php
Ambito
testing-qa

Direzione di ricerca

Start by reading the form analysis rules and tests in phpstan-drupal that cover Drupal form validation and submit handlers. Trace how handler names are resolved, then add cases for missing functions in both #validate and #submit and verify that existing valid handlers still pass. Done means analysis reports each missing handler.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

enhancement

Feature request

Let's say I'm altering a form and I'm adding:

function MYMODULE_form_alter(array &$form, FormStateInterface $form_state) {
    $form['#validate'][] = 'this_function_does_not_exist';
}

it would be nice if I got an error if this_function_does_not_exist() is not a function. Same for the submit hander:

function MYMODULE_form_alter(array &$form, FormStateInterface $form_state) {
    foreach (array_keys($form['actions']) as $action) {
      if ($action != 'preview' && isset($form['actions'][$action]['#type']) && $form['actions'][$action]['#type'] === 'submit') {
        $form['actions'][$action]['#submit'][] = 'this_function_does_not_exist_either';
      }
    }
}

Would be nice if we throw an error if this_function_does_not_exist_either() does not exist.

Lingua principale
PHP
Stelle
208
Fork
88
Merge medio
2g 17h
PR unite (30g)
15

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di mglaman/phpstan-drupal

Tutte le issue di mglaman/phpstan-drupal

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.