diff --git a/bhl.inc.php b/bhl.inc.php index f1b31ed..ad741b2 100644 --- a/bhl.inc.php +++ b/bhl.inc.php @@ -264,6 +264,7 @@ function bhl_validate_func_ref(string $module_file, string $func_full_name, arra $namespace = implode('.', $name_items); $module_src = file_get_contents($module_file); + $module_src = _bhl_remove_comments($module_src); if(!$module_src) throw new Exception("Bad module file '{$module_file}'"); @@ -317,6 +318,23 @@ function bhl_validate_func_ref(string $module_file, string $func_full_name, arra throw new Exception("Func '$func_full_name(".implode(',', $signature).")' not found in '$module_file'"); } +function _bhl_remove_comments(string $txt) : string +{ + //block comments + if(strpos($txt, '/*') !== false) + { + $regex = '~/\*.*?\*/~s'; + $txt = preg_replace_callback( + $regex, + //preserve the new lines for better error reporting + function($m) { return str_repeat("\n", substr_count($m[0], "\n")); }, + $txt); + } + //line comments + $txt = preg_replace("~\s*(?