Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Add filter for skipping files earlier in the pipeline than 'wp_parser_pre_import_file'

オープン
#198 コメント 3 件 リアクション 2 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
42/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
php
領域
documentation

調査の方向性

WP_Parser\get_wp_files() から始め、そのファイル検出フローを WP_Parser\Importer::import_file() にある既存の wp_parser_pre_import_file フィルターと比較します。提案されているファイル引数とディレクトリ引数を指定して、より早い段階のフィルターを追加し、そこで拒否されたファイルが解析もインポートもされないことを確認します。

索引モデルが issue の本文から書いたものです。

説明

enhancement

\\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;
}
主要言語
PHP
スター
239
フォーク
81
平均マージ
1日 22時間
マージ済み PR(30日)
5

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

WordPress/phpdoc-parser のほかの issue

WordPress/phpdoc-parser の issue をすべて見る

似ている issue

PHP の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。