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

Function paths_match

src/phpstan.rs:372–385  ·  view source on GitHub ↗

Check whether two file paths refer to the same file. PHPStan normalizes paths to absolute form. We compare by checking suffix matches (one path ends with the other) to handle cases where one path is relative and the other is absolute, or where symlinks produce different prefixes.

(a: &str, b: &str)

Source from the content-addressed store, hash-verified

370/// one path is relative and the other is absolute, or where symlinks
371/// produce different prefixes.
372fn paths_match(a: &str, b: &str) -> bool {
373 if a == b {
374 return true;
375 }
376 // Normalize separators for comparison.
377 let a_norm = a.replace('\\', "/");
378 let b_norm = b.replace('\\', "/");
379 if a_norm == b_norm {
380 return true;
381 }
382 // Check suffix match (one is a suffix of the other), requiring a
383 // path separator boundary so that e.g. "AFoo.php" does not match "Foo.php".
384 a_norm.ends_with(&format!("/{}", b_norm)) || b_norm.ends_with(&format!("/{}", a_norm))
385}
386
387/// Strip Symfony Console ANSI-style tags like `<fg=cyan>` and `</>`.
388fn strip_ansi_tags(s: &str) -> String {

Callers 1

parse_phpstan_jsonFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected