function coder_upgrade_convert_require in Coder 7
Same name and namespace in other branches
- 7.2 coder_upgrade/conversions/call.inc \coder_upgrade_convert_require()
Updates require() and its siblings.
1 call to coder_upgrade_convert_require()
- coder_upgrade_upgrade_call_alter in coder_upgrade/
conversions/ call.inc - Implements hook_upgrade_call_alter().
File
- coder_upgrade/
conversions/ call.inc, line 2217 - Provides conversion routines applied to function calls.
Code
function coder_upgrade_convert_require(&$item, &$reader) {
// DONE
cdp(__FUNCTION__);
// Create helper objects.
$editor = PGPEditor::getInstance();
// These language elements are included by $reader in function call list.
// Use with http://drupal.org/node/224333#absolute_includes
// Eliminate parentheses (if any).
$item->noparens = 1;
// Get first parameter.
$p0 = $item
->getParameter();
$operand = $p0
->getElement();
if ($operand instanceof PGPOperand && $operand
->findNode('type') == T_STRING && $operand
->findNode('value') == 'DRUPAL_ROOT') {
// Nothing to change.
cdp('leaving the routine');
return;
}
if (is_array($operand) && $operand['type'] == T_CONSTANT_ENCAPSED_STRING) {
if (strpos($operand['value'], "'./'") === 0) {
// if ($operand['value'][0] == '.') {
cdp('found ./');
// Remove './' from the beginning of the string.
$operand['value'] = str_replace('./', '', $operand['value']);
cdp('value = ' . $operand['value']);
if ($operand['value'] == "''" || $operand['value'] == '""') {
cdp('deleteElement');
$p0
->deleteElement();
$p0
->deleteElement();
// This should be a concatenation operator.
}
}
}
// Prepend DRUPAL_ROOT before existing expression.
$editor
->setParameter($item, 0, "DRUPAL_ROOT . '/' . " . $p0
->toString());
}