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

Function scan_directory_for_classes

src/composer.rs:581–600  ·  view source on GitHub ↗

Recursively scan a directory for PHP files and extract class names using the lightweight byte-level scanner.

(dir: &Path, classmap: &mut HashMap<String, PathBuf>)

Source from the content-addressed store, hash-verified

579/// Recursively scan a directory for PHP files and extract class names
580/// using the lightweight byte-level scanner.
581fn scan_directory_for_classes(dir: &Path, classmap: &mut HashMap<String, PathBuf>) {
582 let entries = match fs::read_dir(dir) {
583 Ok(e) => e,
584 Err(_) => return,
585 };
586
587 for entry in entries.flatten() {
588 let path = entry.path();
589 if path.is_dir() {
590 scan_directory_for_classes(&path, classmap);
591 } else if path.extension().is_some_and(|ext| ext == "php")
592 && let Ok(content) = fs::read(&path)
593 {
594 let classes = crate::classmap_scanner::find_classes(&content);
595 for fqn in classes {
596 classmap.entry(fqn).or_insert_with(|| path.clone());
597 }
598 }
599 }
600}
601
602/// Detect `.phar` archive references in a PHP bootstrap file.
603///

Callers 1

Calls 2

find_classesFunction · 0.85
cloneMethod · 0.80

Tested by

no test coverage detected