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)
| 235 | /// - `"Function foo() throws checked exception Ns\Ex but ..."` |
| 236 | /// - `"Get hook for property Ns\Cls::$prop throws checked exception Ns\Ex but ..."` |
| 237 | pub(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). |
| 251 | struct DocblockInfo { |