MCPcopy Create free account
hub / github.com/PHPantom-dev/phpantom_lsp / collect_php_files

Function collect_php_files

src/classmap_scanner.rs:1759–1796  ·  view source on GitHub ↗

Collect all `.php` file paths under a directory using gitignore-aware walking. Paths are appended to `out`. No file content is read. Uses the `ignore` crate's `WalkBuilder` to respect `.gitignore` rules at every level. Hidden directories are skipped automatically. Directories whose absolute path is in `vendor_dir_paths` are also skipped. Individual files whose path appears in `skip_paths` are

(
    dir: &Path,
    vendor_dir_paths: &[PathBuf],
    skip_paths: &HashSet<PathBuf>,
    out: &mut Vec<PathBuf>,
)

Source from the content-addressed store, hash-verified

1757/// skipped. Individual files whose path appears in `skip_paths` are
1758/// excluded (used by the merged classmap + self-scan pipeline).
1759fn collect_php_files(
1760 dir: &Path,
1761 vendor_dir_paths: &[PathBuf],
1762 skip_paths: &HashSet<PathBuf>,
1763 out: &mut Vec<PathBuf>,
1764) {
1765 use ignore::WalkBuilder;
1766
1767 let vendor_paths: Vec<PathBuf> = vendor_dir_paths.to_vec();
1768
1769 let walker = WalkBuilder::new(dir)
1770 .git_ignore(true)
1771 .git_global(true)
1772 .git_exclude(true)
1773 .hidden(true)
1774 .parents(true)
1775 .ignore(true)
1776 .filter_entry(move |entry| {
1777 if entry.file_type().is_some_and(|ft| ft.is_dir()) {
1778 let path = entry.path();
1779 if vendor_paths.iter().any(|vp| vp == path) {
1780 return false;
1781 }
1782 }
1783 true
1784 })
1785 .build();
1786
1787 for entry in walker.flatten() {
1788 let path = entry.path();
1789 if path.is_file() && path.extension().is_some_and(|ext| ext == "php") {
1790 let owned = path.to_path_buf();
1791 if !skip_paths.contains(&owned) {
1792 out.push(owned);
1793 }
1794 }
1795 }
1796}
1797
1798/// Collect all `.php` file paths under a PSR-4 directory, computing the
1799/// expected FQN for each file from its relative path. Paths and

Callers 3

scan_directoriesFunction · 0.70

Calls 4

buildMethod · 0.80
iterMethod · 0.80
containsMethod · 0.80
pushMethod · 0.80

Tested by

no test coverage detected