Parse a single `'key' => 'value',` line.
(line: &str)
| 608 | |
| 609 | /// Parse a single `'key' => 'value',` line. |
| 610 | fn parse_map_entry(line: &str) -> Option<(String, String)> { |
| 611 | // Strip leading whitespace and trailing comma. |
| 612 | let trimmed = line.trim().trim_end_matches(','); |
| 613 | |
| 614 | // Split on ` => `. |
| 615 | let (lhs, rhs) = trimmed.split_once(" => ")?; |
| 616 | |
| 617 | // Strip surrounding single quotes. |
| 618 | let key = lhs.trim().strip_prefix('\'')?.strip_suffix('\'')?; |
| 619 | let value = rhs.trim().strip_prefix('\'')?.strip_suffix('\'')?; |
| 620 | |
| 621 | // Unescape PHP single-quoted string escapes: |
| 622 | // `\\` → `\` and `\'` → `'` |
| 623 | // This is needed because the PhpStormStubsMap.php file uses PHP |
| 624 | // single-quoted strings where namespace separators are written as |
| 625 | // `\\` (e.g. `'Couchbase\\GetUserOptions'` → `Couchbase\GetUserOptions`). |
| 626 | let key = php_unescape_single_quoted(key); |
| 627 | let value = php_unescape_single_quoted(value); |
| 628 | |
| 629 | Some((key, value)) |
| 630 | } |
| 631 | |
| 632 | /// Unescape a PHP single-quoted string value. |
| 633 | /// |
no test coverage detected