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

Function parse_map_entry

build.rs:610–630  ·  view source on GitHub ↗

Parse a single `'key' => 'value',` line.

(line: &str)

Source from the content-addressed store, hash-verified

608
609/// Parse a single `'key' => 'value',` line.
610fn 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///

Callers 1

parse_sectionFunction · 0.85

Calls 1

Tested by

no test coverage detected