- Модуль: main
- Путь к файлу: ~/bitrix/modules/main/classes/general/php_parser.php
- Класс: PHPParser
- Вызов: PHPParser::FindComponent
static function FindComponent($component_name, $filesrc, $src_line)
{
/* parse source file for PHP code */
$arComponents = PHPParser::ParseScript($filesrc);
/* identify the component by line number */
$arComponent = false;
for ($i = 0, $cnt = count($arComponents); $i < $cnt; $i++)
{
$nLineFrom = substr_count(mb_substr($filesrc, 0, $arComponents[$i]["START"]), "n") + 1;
$nLineTo = substr_count(mb_substr($filesrc, 0, $arComponents[$i]["END"]), "n") + 1;
if ($nLineFrom <= $src_line && $nLineTo >= $src_line)
{
if ($arComponents[$i]["DATA"]["COMPONENT_NAME"] == $component_name)
{
$arComponent = $arComponents[$i];
break;
}
}
if ($nLineTo > $src_line)
break;
}
return $arComponent;
}