Automattic / Automattic/VIP-Coding-Standards
Flag incorrect use of filter (instead of action) before AlwaysReturnSniff
- Lingua principale
- PHP
- Stelle
- 261
- Fork
- 44
- Merge medio
- 19m
- PR unite (30g)
- 1
Descrizione
## What problem would the enhancement address for VIP?
Code that uses a filter instead of an action are being flagged with `WordPressVIPMinimum.Filters.AlwaysReturn.missingReturnStatement` when the correct developer remediation for the problematic code should be to change it to `add_action`
## Describe the solution you'd like
Flag use of `add_filter` on hooks that are most definitely only supposed to use `add_action`
Even better, use GitHub "suggestions" to show the correct change.
## What code should be reported as a violation?
`add_filter( 'rss2_item', 'attached_images' );`
## What code should *not* be reported as a violation?
`add_filter( 'the_content', 'my_filter_content' );`
## Additional context
If this raises a flag, then the `WordPressVIPMinimum.Filters.AlwaysReturn.missingReturnStatement` sniff should NOT.
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia esaminando lo sniff WordPressVIPMinimum.Filters.AlwaysReturn.missingReturnStatement e il modo in cui gestisce le chiamate a add_filter. Confronta gli esempi forniti rss2_item e the_content, quindi definisci l’elenco degli hook e l’interazione necessaria affinché vengano segnalati gli hook usati solo per le azioni, ma non la violazione per la mancanza del valore di ritorno; il lavoro è completato quando questi due esempi producono i risultati richiesti.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- php
- Ambito
- devtools, tooling
- Tipo di issue
- Funzionalità
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100