You are here

function drush_devel_fn_view in Devel 8

Same name and namespace in other branches
  1. 8.3 drush/devel.drush8.inc \drush_devel_fn_view()
  2. 8.2 drush/devel.drush8.inc \drush_devel_fn_view()
  3. 6 devel.drush.inc \drush_devel_fn_view()
  4. 7 devel.drush.inc \drush_devel_fn_view()

Command handler. Show source code of specified function or method.

2 calls to drush_devel_fn_view()
drush_devel_fn_event in drush/devel.drush8.inc
Command handler. Show hook implementations.
drush_devel_fn_hook in drush/devel.drush8.inc
Command handler. Show hook implementations.

File

drush/devel.drush8.inc, line 168
This file is only used by Drush8. Drush9 discovers its commands via tagged service(s) in devel.services.yml. Also see classes in src/Commands.

Code

function drush_devel_fn_view($function_name) {

  // Get implementations in the .install files as well.
  include_once './core/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());
}