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

Function resolve_autoload_path_entry

src/composer.rs:250–266  ·  view source on GitHub ↗

Resolve a single path entry from `autoload_psr4.php`. Handles `$vendorDir . '/path'` and `$baseDir . '/path'`.

(entry: &str, vendor_dir: &str)

Source from the content-addressed store, hash-verified

248///
249/// Handles `$vendorDir . '/path'` and `$baseDir . '/path'`.
250fn resolve_autoload_path_entry(entry: &str, vendor_dir: &str) -> Option<String> {
251 let entry = entry.trim();
252
253 if let Some(rest) = entry.strip_prefix("$vendorDir . '") {
254 // $vendorDir . '/org/pkg/src'
255 let path = rest.strip_suffix('\'')?;
256 let path = path.strip_prefix('/').unwrap_or(path);
257 Some(format!("{}/{}", vendor_dir, path))
258 } else if let Some(rest) = entry.strip_prefix("$baseDir . '") {
259 // $baseDir . '/lib'
260 let path = rest.strip_suffix('\'')?;
261 let path = path.strip_prefix('/').unwrap_or(path);
262 Some(path.to_string())
263 } else {
264 None
265 }
266}
267
268/// Parse `<vendor>/composer/autoload_files.php` and return the resolved
269/// file paths.

Callers 3

parse_autoload_classmapFunction · 0.85
parse_autoload_filesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected