diff --git a/src/analyzer/custom_hook.rs b/src/analyzer/custom_hook.rs index 1f027736..9309014d 100644 --- a/src/analyzer/custom_hook.rs +++ b/src/analyzer/custom_hook.rs @@ -152,6 +152,9 @@ pub trait InternalHook { ) -> bool { false } + + #[allow(unused_variables)] + fn after_populate(&self, codebase: &CodebaseInfo, interner: &Interner) {} } pub trait CustomHook: InternalHook + Send + Sync + core::fmt::Debug {} diff --git a/src/analyzer/function_analysis_data.rs b/src/analyzer/function_analysis_data.rs index 995de0be..394023de 100644 --- a/src/analyzer/function_analysis_data.rs +++ b/src/analyzer/function_analysis_data.rs @@ -583,27 +583,34 @@ fn get_hakana_fixmes_and_ignores( ) -> BTreeMap> { let mut hakana_fixme_or_ignores = BTreeMap::new(); for (pos, comment) in comments { - if let Comment::CmtBlock(text) = comment { - let trimmed_text = if let Some(trimmed_text) = text.strip_prefix('*') { - trimmed_text.trim() - } else { - text.trim() - }; - - if let Some(Ok(issue_kind)) = get_issue_from_comment(trimmed_text, all_custom_issues) { - hakana_fixme_or_ignores - .entry(pos.line() as u32) - .or_insert_with(Vec::new) - .push(( - issue_kind, - ( - pos.start_offset() as u32, - pos.end_offset() as u32, - pos.to_raw_span().start.beg_of_line() as u32, - pos.end_offset() as u32, - false, - ), - )); + match comment { + Comment::CmtBlock(text) => { + let trimmed_text = if let Some(trimmed_text) = text.strip_prefix('*') { + trimmed_text.trim() + } else { + text.trim() + }; + + if let Some(Ok(issue_kind)) = + get_issue_from_comment(trimmed_text, all_custom_issues) + { + hakana_fixme_or_ignores + .entry(pos.line() as u32) + .or_insert_with(Vec::new) + .push(( + issue_kind, + ( + pos.start_offset() as u32, + pos.end_offset() as u32, + pos.to_raw_span().start.beg_of_line() as u32, + pos.end_offset() as u32, + false, + ), + )); + } + } + Comment::CmtLine(_) => { + // do nothing — if we handle issues here things are much slower } } } diff --git a/src/code_info/issue.rs b/src/code_info/issue.rs index 46eaa6bf..f0923e43 100644 --- a/src/code_info/issue.rs +++ b/src/code_info/issue.rs @@ -15,6 +15,7 @@ use crate::{ #[derive(Clone, PartialEq, Eq, Hash, Display, Debug, Serialize, Deserialize, EnumString)] pub enum IssueKind { AbstractInstantiation, + BannedFunction, ExtendFinalClass, CannotInferGenericParam, CustomIssue(Box), @@ -317,6 +318,10 @@ pub fn get_issue_from_comment( return Some(Ok(IssueKind::NoJoinInAsyncFunction)); } else if trimmed_text.starts_with("HHAST_FIXME[FinalOrAbstractClass]") { return Some(Ok(IssueKind::MissingFinalOrAbstract)); + } else if trimmed_text.starts_with("HHAST_FIXME[BannedFunctions]") + || trimmed_text.starts_with("HHAST_IGNORE_ERROR[BannedFunctions]") + { + return Some(Ok(IssueKind::BannedFunction)); } None diff --git a/src/file_scanner_analyzer/lib.rs b/src/file_scanner_analyzer/lib.rs index 53aaf100..f5c91ad7 100644 --- a/src/file_scanner_analyzer/lib.rs +++ b/src/file_scanner_analyzer/lib.rs @@ -282,6 +282,10 @@ pub fn scan_and_analyze( cached_analysis.safe_symbol_members, ); + for hook in &config.hooks { + hook.after_populate(&codebase, &interner); + } + let populating_elapsed = populating_now.elapsed(); if logger.can_log_timing() {