AlwaysReturnInFilter: isInsideIfConditonal() guards the conditions array after reading it
Una pull request collegata è già stata integrata.
- #905 di @tomjn — integrata
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 78/100
Direzione di ricerca
Inizia da AlwaysReturnInFilterSniff::isInsideIfConditonal() e analizza come viene letto l'array conditions del token. Semplifica la logica di guard e reset come descritto, quindi verifica che lo sniff segnali ancora gli stessi casi; il lavoro è terminato quando la pulizia preserva il comportamento delle segnalazioni.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
This is a tidy-up. It does not change what the sniff reports.
AlwaysReturnInFilterSniff::isInsideIfConditonal() decides whether a return in a filter callback sits inside an if. It has a guard for a token that has no conditions array, but the guard comes after two end() calls that have already read that array, so it protects nothing. PHP_CodeSniffer sets conditions on every token, so the guard is not needed in the first place.
The reset() call between the two has no effect on the result either. It only undoes the array pointer move that end() made on the shared token array.
The method can read the array once, return false when the innermost condition is a function or closure, and otherwise return in_array( T_IF, $conditions, true ).
@GaryJones spotted this while reviewing #901. It was left out of that PR because that one only adds return types.
- Lingua principale
- PHP
- Stelle
- 261
- Fork
- 44
- Merge medio
- 3g 17h
- PR unite (30g)
- 9
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di Automattic/VIP-Coding-Standards
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 48/100
-
Breaking Change Type: Maintenance
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
Automattic/VIP-Coding-Standards#849 · 1 commento ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
-
WordPress.WP.AlternativeFunctions.file_system_operations error messages cannot be fixed anymoreAperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 48/100
-
Status: Awaiting feedback
Difficoltà 2/5 1-3 ore Idoneità per principianti 45/100
Automattic/VIP-Coding-Standards#754 · 3 commenti ·
Tutte le issue di Automattic/VIP-Coding-Standards
Issue simili
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 84/100
WordPress/hosting-handbook#506 ·
I maintainer di solito rispondono entro 2 giorni
-
Installing a plugin with composer_packages installs dev dependencies and breaks the autoloader (Error 500)Forse già presa @Boy132 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
nginx: static-file locations drop the security headers, and the dotfile deny is matched after themApertabug Low Security
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
backdrop-contrib/commerce#60 ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 76/100