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

Function parse_string_list

src/parser/classes.rs:761–788  ·  view source on GitHub ↗

Parse a PHP array literal containing only string values. Accepts text starting with `[` and extracts bare string values (no `=>` keys). For example, `['name', 'email', 'password']` returns `["name", "email", "password"]`.

(text: &str)

Source from the content-addressed store, hash-verified

759/// (no `=>` keys). For example, `['name', 'email', 'password']`
760/// returns `["name", "email", "password"]`.
761fn parse_string_list(text: &str) -> Vec<String> {
762 let mut results = Vec::new();
763 let trimmed = text.trim();
764
765 let inner = if let Some(s) = trimmed.strip_prefix('[') {
766 s.strip_suffix(']').unwrap_or(s)
767 } else {
768 return results;
769 };
770
771 for segment in inner.split(',') {
772 let segment = segment.trim();
773 if segment.is_empty() {
774 continue;
775 }
776 // Skip key-value pairs (these belong to a different kind of array).
777 if segment.contains("=>") {
778 continue;
779 }
780 if let Some(s) = extract_string_literal(segment)
781 && !s.is_empty()
782 {
783 results.push(s);
784 }
785 }
786
787 results
788}
789
790/// Try to infer an Eloquent relationship return type from a method's body.
791///

Callers 2

extract_column_namesFunction · 0.85

Calls 4

containsMethod · 0.80
pushMethod · 0.80
extract_string_literalFunction · 0.70
is_emptyMethod · 0.45

Tested by

no test coverage detected