Exemplo n.º 1
0
 public function testGetBasicFunctionRenames()
 {
     $fixes = new \CodeReview\CodeFixer();
     $renames = $fixes->getBasicFunctionRenames();
     $pattern = '/^[a-zA-Z_][\\sa-zA-Z_0-9\\(\\)\\->]*$/';
     foreach ($renames as $from => $to) {
         $this->assertNotEmpty($from);
         $this->assertNotEmpty($to);
         $this->assertRegExp($pattern, $from);
         $this->assertRegExp($pattern, $to);
     }
     /*
      * Check version filtering
      */
     // no results below 1.7
     $this->assertEmpty($fixes->getBasicFunctionRenames('1.6'));
     // version 1.7
     $renames = $fixes->getBasicFunctionRenames('1.7');
     $this->assertArrayHasKey('elgg_validate_action_url', $renames);
     $this->assertArrayNotHasKey('register_elgg_event_handler', $renames);
     $this->assertArrayNotHasKey('setup_db_connections', $renames);
     // version 1.8
     $renames = $fixes->getBasicFunctionRenames('1.8');
     $this->assertArrayHasKey('elgg_validate_action_url', $renames);
     $this->assertArrayHasKey('register_elgg_event_handler', $renames);
     $this->assertArrayNotHasKey('setup_db_connections', $renames);
     // version 1.9
     $renames = $fixes->getBasicFunctionRenames('1.9');
     $this->assertArrayHasKey('elgg_validate_action_url', $renames);
     $this->assertArrayHasKey('register_elgg_event_handler', $renames);
     $this->assertArrayHasKey('setup_db_connections', $renames);
     // all versions
     $renames = $fixes->getBasicFunctionRenames('');
     $this->assertArrayHasKey('elgg_validate_action_url', $renames);
     $this->assertArrayHasKey('register_elgg_event_handler', $renames);
     $this->assertArrayHasKey('setup_db_connections', $renames);
 }
Exemplo n.º 2
0
echo elgg_view('code_review/navigation');
//fetch all
$functions = code_review::getDeprecatedFunctionsList('');
//group by versions
$groups = array();
foreach ($functions as $name => $data) {
    $version = isset($data['version']) ? $data['version'] : 'Unknown';
    if (!isset($groups[$version])) {
        $groups[$version] = array();
    }
    $groups[$version][$name] = $data;
}
uksort($groups, 'version_compare');
$groups = array_reverse($groups, true);
$fixes = new \CodeReview\CodeFixer();
$replaces = $fixes->getBasicFunctionRenames();
foreach ($groups as $version => $group) {
    $title = elgg_echo('code_review:deprecated_list:title', array($version));
    $body = "<table class=\"elgg-table-alt\">";
    $body .= "<tr>" . "<th><strong>" . elgg_echo('code_review:deprecated_list:name') . "</strong></th>" . "<th><strong>" . elgg_echo('code_review:deprecated_list:remarks') . "</strong></th>" . "<th><strong>" . elgg_echo('code_review:deprecated_list:solution') . "</strong></th>" . "</tr>";
    ksort($group, SORT_STRING);
    foreach ($group as $name => $data) {
        $fileLine = elgg_echo('code_review:deprecated_list:file_line', array($data['file'], $data['line']));
        $body .= "<tr><td><abbr title=\"{$fileLine}\">" . $data['name'] . "</abbr></td>";
        $body .= "<td>" . ($data['fixinfoshort'] ? $data['fixinfoshort'] : '') . '</td>';
        $solution = '';
        if (isset($replaces[$name])) {
            $solution = elgg_echo('code_review:solution:basic_replace_with', array($replaces[$name]));
        }
        $body .= "<td>" . $solution . "</td>" . "</tr>";