Skip to content

Instantly share code, notes, and snippets.

@Sam152
Last active January 3, 2016 05:09
Show Gist options
  • Save Sam152/8413868 to your computer and use it in GitHub Desktop.
Save Sam152/8413868 to your computer and use it in GitHub Desktop.
Find what has changed since D7 and D8.
<?php
// ctags --langmap=php:.engine.inc.module.theme.install.php --php-kinds=cdfi --languages=php --recurse
function only_first_part($array) {
$delim = "\t";
foreach ($array as $i => &$line) {
$parts = explode($delim, $line);
$line = $parts[0];
}
return $array;
}
function filter_crap($array) {
$filters = array(
'/update/',
'/ _/',
'/_form_/',
'/_test_/',
'/simpletest/',
'/_submit/',
'/_validate/',
'/template_preprocess/',
'/locale_/',
'/translation_/',
);
foreach ($array as $i => &$line) {
foreach ($filters as $filter) {
$matches = preg_match($filter, $line);
if ($matches === FALSE) {
die('Regex ' . $filter . ' has an error.');
}
if ($matches == 1) {
unset($array[$i]);
}
}
}
return $array;
}
function whitelist_line($array) {
$filters = array(
'/^function (.*)/',
);
$good = array();
foreach ($array as $i => &$line) {
foreach ($filters as $filter) {
$code = explode('/^', $line);
if (sizeof($code) < 2) {
continue;
}
$code = $code[1];
$code = explode('$/' , $code);
$code = $code[0];
foreach ($filters as $filter) {
$matches = preg_match($filter, $code);
if ($matches == 1) {
$good[] = $line;
}
}
}
}
return $good;
}
function key_lines($array) {
$new_array = array();
foreach ($array as $key => $line) {
$parts = explode("\t", $line);
$part = $parts[0];
$new_array[$part] = $line;
}
return $new_array;
}
$d7 = explode("\n", file_get_contents('d7'));
$d8 = explode("\n", file_get_contents('d8'));
$d7 = whitelist_line(filter_crap($d7));
$d8 = whitelist_line($d8);
$d7 = key_lines($d7);
$d8 = key_lines($d8);
$no_longer = array();
foreach ($d7 as $func_name => $line) {
if (in_array($func_name, array_keys($d8))) {
// print $func_name . ' is in D8. <br/>';
} else {
$no_longer[] = $func_name;
print $func_name . ' is no longer in D8. <br/>';
}
}
print 'Total gone: ' . count($no_longer);
// print_r($d7);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment