function CodeTrait::codeLocate
Get source code line for specified function or method.
2 calls to CodeTrait::codeLocate()
- DevelEventCommand::execute in src/
Drush/ Commands/ DevelEventCommand.php - DevelHookCommand::execute in src/
Drush/ Commands/ DevelHookCommand.php
File
-
src/
Drush/ Commands/ CodeTrait.php, line 10
Class
Namespace
Drupal\devel\Drush\CommandsCode
public function codeLocate($function_name) : array {
// Get implementations in the .install files as well.
include_once DRUPAL_ROOT . '/core/includes/install.inc';
drupal_load_updates();
if (!str_contains($function_name, '::')) {
if (!function_exists($function_name)) {
throw new \Exception(dt('Function not found'));
}
$reflect = new \ReflectionFunction($function_name);
}
else {
[$class, $method] = explode('::', $function_name);
if (!method_exists($class, $method)) {
throw new \Exception(dt('Method not found'));
}
$reflect = new \ReflectionMethod($class, $method);
}
return [
'file' => $reflect->getFileName(),
'startline' => $reflect->getStartLine(),
'endline' => $reflect->getEndLine(),
];
}