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)
| 154 | /// like `'prefix_' . 'suffix'`. Each segment must be a string literal |
| 155 | /// or a numeric literal separated by `.` operators. |
| 156 | fn 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. |
no test coverage detected