function _coder_6x_callback in Coder 5
Same name and namespace in other branches
- 5.2 includes/coder_6x.inc \_coder_6x_callback()
- 6.2 includes/coder_6x.inc \_coder_6x_callback()
- 6 includes/coder_6x.inc \_coder_6x_callback()
1 string reference to '_coder_6x_callback'
- coder_6x_reviews in includes/
coder_6x.inc - @file This include file implements coder functionality for 5.x -> 6.x upgrades
File
- includes/
coder_6x.inc, line 195 - This include file implements coder functionality for 5.x -> 6.x upgrades
Code
function _coder_6x_callback(&$coder_args, $review, $rule, $lines, &$results) {
// only perform this check on module's (not includes)
$filename = $coder_args['#filename'];
if (substr($filename, -7) == '.module') {
// if there are any theme functions, make sure that a hook_theme exists
$theme = false;
$hook_theme = false;
foreach ($lines as $lineno => $line) {
if (preg_match('/function theme_/', $line)) {
if (!$theme) {
$theme = true;
$theme_line = $line;
$theme_lineno = $lineno;
}
}
if (preg_match('/function \\w+_theme\\(/', $line)) {
$hook_theme = true;
}
}
if ($theme && !$hook_theme) {
$severity_name = _coder_severity_name($coder_args, $review, $rule);
$warning = _coder_6x_hook_theme_warning();
$results[0] = theme('coder_warning', $warning, $severity_name, $theme_lineno, $theme_line);
}
// read the .info file
$filename = drupal_substr(realpath($filename), 0, -7) . '.info';
if (file_exists($filename)) {
if ($lines = file($filename)) {
foreach ($lines as $lineno => $line) {
if (preg_match('/^dependencies\\s*=/', $line)) {
$severity_name = _coder_severity_name($coder_args, $review, $rule);
$warning = t('New syntax for .info files, use dependencies[]');
$results[-1] = theme('coder_warning', $warning, $severity_name, $lineno, $line);
}
if (preg_match('/^core\\s*=/', $line)) {
$core = TRUE;
}
}
if (!isset($core)) {
$severity_name = _coder_severity_name($coder_args, $review, $rule);
$warning = t('New syntax for .info files requires core=6.x');
$results[-1] = theme('coder_warning', $warning, $severity_name, $lineno, $line);
}
}
}
}
}