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

Function extract_column_names

src/parser/classes.rs:684–716  ·  view source on GitHub ↗

Extract column names from `$fillable`, `$guarded`, `$hidden`, and `$appends` arrays. These properties contain simple string lists of column names without type information. The `LaravelModelProvider` uses them as a last-resort fallback, synthesizing `mixed`-typed virtual properties for columns not already covered by `$casts` or `$attributes`. All four arrays are merged; duplicates are removed (f

(
    members: impl Iterator<Item = &'a ClassLikeMember<'a>>,
    content: &str,
)

Source from the content-addressed store, hash-verified

682/// All four arrays are merged; duplicates are removed (first occurrence
683/// wins).
684fn extract_column_names<'a>(
685 members: impl Iterator<Item = &'a ClassLikeMember<'a>>,
686 content: &str,
687) -> Vec<String> {
688 let mut names = Vec::new();
689 let targets = ["fillable", "guarded", "hidden", "visible", "appends"];
690
691 for member in members {
692 if let ClassLikeMember::Property(Property::Plain(plain)) = member {
693 for item in plain.items.iter() {
694 let var_name = item.variable().name.to_string();
695 let stripped = var_name.strip_prefix('$').unwrap_or(&var_name);
696 if !targets.contains(&stripped) {
697 continue;
698 }
699 if let PropertyItem::Concrete(concrete) = item {
700 let span = concrete.value.span();
701 let start = span.start.offset as usize;
702 let end = span.end.offset as usize;
703 if let Some(text) = content.get(start..end) {
704 for name in parse_string_list(text) {
705 if !names.contains(&name) {
706 names.push(name);
707 }
708 }
709 }
710 }
711 }
712 }
713 }
714
715 names
716}
717
718/// Extract column names from the deprecated `$dates` property array.
719///

Callers 1

Calls 5

parse_string_listFunction · 0.85
iterMethod · 0.80
containsMethod · 0.80
pushMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected