You are here

function coder_upgrade_convert_function_calls in Coder 7

Same name in this branch
  1. 7 coder_upgrade/includes/main.inc \coder_upgrade_convert_function_calls()
  2. 7 coder_upgrade/conversions/other.inc \coder_upgrade_convert_function_calls()
Same name and namespace in other branches
  1. 7.2 coder_upgrade/includes/main.inc \coder_upgrade_convert_function_calls()
  2. 7.2 coder_upgrade/conversions/other.inc \coder_upgrade_convert_function_calls()

Upgrades function calls using grammar parser.

Parameters

PGPReader $reader: The object containing the grammar statements of the file to convert.

1 call to coder_upgrade_convert_function_calls()
coder_upgrade_apply_parser in coder_upgrade/includes/main.inc
Applies grammar parser conversion routines to a file.

File

coder_upgrade/includes/main.inc, line 410
Manages application of conversion routines, logging, and patch file creation.

Code

function coder_upgrade_convert_function_calls(&$reader) {
  cdp("inside " . __FUNCTION__);
  $nodes =& $reader
    ->getFunctionCalls();
  foreach ($nodes as &$node) {
    $item =& $node->data;
    if (!isset($item) || !is_object($item) || !$item instanceof PGPFunctionCall || $item->type != T_FUNCTION_CALL) {

      // The reference could have been changed in another routine so that it
      // no longer refers to an object.
      continue;
    }

    // If need to change other statements that we build as a function call,
    // then modify the next line. Others: eval, empty, unset, print, throw.
    $types = array(
      T_STRING,
      T_REQUIRE,
      T_REQUIRE_ONCE,
      T_INCLUDE,
      T_INCLUDE_ONCE,
    );
    if (is_array($item->name) && in_array($item->name['type'], $types)) {

      // If name is an object, then it is a variable expression that is not
      // 'alterable' in the traditional sense.
      drupal_alter('upgrade_call_' . $item->name['value'], $node, $reader);

      // TODO The alter hooks can get the $reader from PGPReader::getInstance();
      // We could do the same in this function.
    }
    if (!isset($node) || !is_object($node) || !$node instanceof PGPNode) {
      continue;
    }
    $item =& $node->data;
    if (!isset($item) || !is_object($item) || !$item instanceof PGPFunctionCall || $item->type != T_FUNCTION_CALL) {
      continue;
    }
    if (is_array($item->name) && in_array($item->name['type'], $types)) {

      // Set name because only variables may be passed by reference.
      $name = $item->name['value'];
      drupal_alter('upgrade_call', $node, $reader, $name);

      // TODO The alter hooks can get the $reader from PGPReader::getInstance();
      // We could do the same in this function.
    }
  }
}