Adding stripping of commented code during detection of BHL func signatures
Publish PHP Package / docker (push) Successful in 6s
Details
Publish PHP Package / docker (push) Successful in 6s
Details
This commit is contained in:
parent
63dee1f015
commit
9c4c4521d8
18
bhl.inc.php
18
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*(?<!:)//.*~", "\n", $txt);
|
||||
return $txt;
|
||||
}
|
||||
|
||||
function _bhl_split_by_namespaces(string $src) : array
|
||||
{
|
||||
$nss = array();
|
||||
|
|
Loading…
Reference in New Issue