Add filter for skipping files earlier in the pipeline than 'wp_parser_pre_import_file'
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 42/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- php
- Ambito
- documentation
Direzione di ricerca
Inizia da WP_Parser\get_wp_files() e confronta il relativo flusso di individuazione dei file con il filtro wp_parser_pre_import_file esistente in WP_Parser\Importer::import_file(). Aggiungi il filtro precedente con gli argomenti file e directory proposti e conferma che i file rifiutati in quel punto non vengano analizzati né importati.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
\\WP_Parser\Importer::import_file() provides the wp_parser_pre_import_file filter to skip importing a particular file.
It would improve efficiency if there were a similar filter earlier in the pipeline, e.g., in \\WP_Parser\get_wp_files(). For example,
function get_wp_files( $directory ) {
$iterableFiles = new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator( $directory )
);
$files = array();
try {
foreach ( $iterableFiles as $file ) {
if ( 'php' !== $file->getExtension() ) {
continue;
}
if ( ! apply_filters( 'wp_parser_pre_get_wp_file', true, $file->getPathname(), $directory ) ) {
continue;
}
$files[] = $file->getPathname();
}
} catch ( \UnexpectedValueException $exc ) {
return new \WP_Error(
'unexpected_value_exception',
sprintf( 'Directory [%s] contained a directory we can not recurse into', $directory )
);
}
return $files;
}
I use this plugin to produce developer documentation for plugins/themes I create for clients, and currently hook into wp_parser_pre_import_file to skip importing anything in tests/ or vendor/ sub-dirs of a plugin/theme. Having the proposed wp_parser_pre_get_wp_file hook would allow avoiding the overhead of parsing all those files, only to skip them later in the pipeline.
Here is an example of a func I would hook into the proposed filter, to show why the proposed filter takes the additional $directory param that wp_parser_pre_import_file does not:
add_filter( 'wp_parser_pre_get_wp_file', 'shc_wp_parser_skip_files', 10, 3 );
function shc_wp_parser_skip_files( $default, $file, $directory ) {
$file = str_replace( $directory . DIRECTORY_SEPARATOR, '', $file );
$paths = explode( DIRECTORY_SEPARATOR, $file );
if ( in_array( $paths[1], array( 'tests', 'vendor' ) ) ) {
return false;
}
return $default;
}
- Lingua principale
- PHP
- Stelle
- 239
- Fork
- 81
- Merge medio
- 16h 29m
- PR unite (30g)
- 8
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
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 WordPress/phpdoc-parser
-
Include constants in exports Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
WordPress/phpdoc-parser#269 ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 64/100
WordPress/phpdoc-parser#268 · 1 commento ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
WordPress/phpdoc-parser#254 ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
WordPress/phpdoc-parser#246 · 9 commenti ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
WordPress/phpdoc-parser#235 · 1 commento ·
Tutte le issue di WordPress/phpdoc-parser
Issue simili
-
tooling
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
UX
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
ProfessionalWiki/NeoWiki#1525 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
OpenConext/OpenConext-engineblock#2122 ·
-
Bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
Automattic/safe-publish#594 ·