function drush_devel_fn_view

A command handler for showing source code of a function or method.

1 call to drush_devel_fn_view()
drush_devel_fn_hook in ./devel.drush.inc
A command handler for showing hook implementations.

File

./devel.drush.inc, line 137

Code

function drush_devel_fn_view($function_name) {
    // Get implementations in the .install files as well.
    include_once './includes/install.inc';
    drupal_load_updates();
    if (strpos($function_name, '::') === FALSE) {
        if (!function_exists($function_name)) {
            return drush_set_error(dt('Function not found'));
        }
        $reflect = new ReflectionFunction($function_name);
    }
    else {
        list($class, $method) = explode('::', $function_name);
        if (!method_exists($class, $method)) {
            return drush_set_error(dt('Method not found'));
        }
        $reflect = new ReflectionMethod($class, $method);
    }
    $func_info = array(
        '!file' => $reflect->getFileName(),
        '!startline' => $reflect->getStartLine(),
        '!endline' => $reflect->getEndLine(),
    );
    $format = drush_get_option('format', '!file');
    drush_print_pipe(dt($format, $func_info));
    drush_print(dt("// file: !file, lines !startline-!endline", $func_info));
    _drush_devel_print_function($reflect->getFileName(), $reflect->getStartLine(), $reflect->getEndLine());
}