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

Function extract_exception_fqn

src/code_actions/phpstan/add_throws.rs:237–248  ·  view source on GitHub ↗

Extract the fully-qualified exception class name from a PHPStan `missingType.checkedException` message. Expected formats: - `"Method Ns\Cls::method() throws checked exception Ns\Ex but ..."` - `"Function foo() throws checked exception Ns\Ex but ..."` - `"Get hook for property Ns\Cls::$prop throws checked exception Ns\Ex but ..."`

(message: &str)

Source from the content-addressed store, hash-verified

235/// - `"Function foo() throws checked exception Ns\Ex but ..."`
236/// - `"Get hook for property Ns\Cls::$prop throws checked exception Ns\Ex but ..."`
237pub(crate) fn extract_exception_fqn(message: &str) -> Option<String> {
238 let marker = "throws checked exception ";
239 let start = message.find(marker)? + marker.len();
240 let rest = &message[start..];
241 let end = rest.find(" but")?;
242 let fqn = rest[..end].trim();
243 if fqn.is_empty() {
244 return None;
245 }
246 // Strip leading backslash if present.
247 Some(strip_fqn_prefix(fqn).to_string())
248}
249
250/// Information about an existing docblock (or the position to create one).
251struct DocblockInfo {

Calls 3

strip_fqn_prefixFunction · 0.85
findMethod · 0.45
is_emptyMethod · 0.45