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

Function is_concat_expression

src/code_actions/extract_constant.rs:156–174  ·  view source on GitHub ↗

Returns `true` when the text is a concatenated string expression like `'prefix_' . 'suffix'`. Each segment must be a string literal or a numeric literal separated by `.` operators.

(text: &str)

Source from the content-addressed store, hash-verified

154/// like `'prefix_' . 'suffix'`. Each segment must be a string literal
155/// or a numeric literal separated by `.` operators.
156fn is_concat_expression(text: &str) -> bool {
157 if !text.contains('.') {
158 return false;
159 }
160
161 // Split on ` . ` (the PHP concatenation operator with typical spacing).
162 // We also handle `.` without spaces.
163 let parts = split_concat_parts(text);
164 if parts.len() < 2 {
165 return false;
166 }
167
168 parts.iter().all(|p| {
169 let t = p.trim();
170 (t.starts_with('\'') && t.ends_with('\'') && t.len() >= 2)
171 || (t.starts_with('"') && t.ends_with('"') && t.len() >= 2)
172 || is_numeric_literal(t)
173 })
174}
175
176/// Split a string on the PHP `.` concatenation operator, respecting
177/// string literal boundaries.

Callers 3

is_extractable_literalFunction · 0.85
generate_constant_nameFunction · 0.85
literal_type_nameFunction · 0.85

Calls 5

split_concat_partsFunction · 0.85
is_numeric_literalFunction · 0.85
containsMethod · 0.80
iterMethod · 0.80
allMethod · 0.45

Tested by

no test coverage detected