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)
| 370 | /// one path is relative and the other is absolute, or where symlinks |
| 371 | /// produce different prefixes. |
| 372 | fn 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 `</>`. |
| 388 | fn strip_ansi_tags(s: &str) -> String { |
no outgoing calls
no test coverage detected