public function testGetPrivateFunctionsList() { $functions = code_review::getPrivateFunctionsList(); $this->assertArrayNotHasKey('dummy_deprecated_function1', $functions); /* * foobar_private_api */ $this->assertArrayHasKey('foobar_private_api', $functions); $privateFunction = $functions['foobar_private_api']; $this->assertInstanceOf('CodeReview_Issues_Private', $privateFunction); $this->assertInstanceOf('ArrayAccess', $privateFunction); $this->assertFalse(is_array($privateFunction)); $this->assertArrayHasKey('name', $privateFunction); $this->assertArrayHasKey('file', $privateFunction); $this->assertArrayHasKey('line', $privateFunction); $this->assertArrayHasKey('reason', $privateFunction); $this->assertEquals('foobar_private_api', $privateFunction['name']); $this->assertEquals('private', $privateFunction['reason']); $this->assertEquals("Line " . $privateFunction['line'] . ":\tFunction call: " . $privateFunction['name'] . " (use of function marked private is unsafe)", (string) $privateFunction); /* * foobar_undocumented */ $this->assertArrayHasKey('foobar_undocumented', $functions); $undocumentedFunction = $functions['foobar_undocumented']; $this->assertInstanceOf('CodeReview_Issues_NotDocumented', $undocumentedFunction); $this->assertInstanceOf('ArrayAccess', $undocumentedFunction); $this->assertFalse(is_array($undocumentedFunction)); $this->assertArrayHasKey('name', $undocumentedFunction); $this->assertArrayHasKey('file', $undocumentedFunction); $this->assertArrayHasKey('line', $undocumentedFunction); $this->assertArrayHasKey('reason', $undocumentedFunction); $this->assertEquals('foobar_undocumented', $undocumentedFunction['name']); $this->assertEquals('not_documented', $undocumentedFunction['reason']); $this->assertEquals("Line " . $undocumentedFunction['line'] . ":\tFunction call: " . $undocumentedFunction['name'] . " (use of undocumented core function is unsafe)", (string) $undocumentedFunction); }
/** * @return array */ public function analyze() { $options = $this->options; $i = $this->getPhpFilesIterator($options->getSubPath()); $fixer = new CodeFixer(); $this->instantReplacements = $fixer->getBasicFunctionRenames($this->maxVersion); $this->stats = array(); $this->filesAnalyzed = 0; $functions = array(); if ($options->isDeprecatedFunctionsTestEnabled()) { $functions = array_merge($functions, \code_review::getDeprecatedFunctionsList($options->getMaxVersion())); } if ($options->isPrivateFunctionsTestEnabled()) { $functions = array_merge($functions, \code_review::getPrivateFunctionsList()); } foreach ($i as $filePath => $file) { if ($file instanceof \SplFileInfo) { $result = $this->processFile($filePath, $functions); $this->filesAnalyzed++; if (!empty($result['problems'])) { $this->stats[$filePath] = $result; } } } return $this->stats; }
<?php echo elgg_view('code_review/navigation'); //fetch all $functions = code_review::getPrivateFunctionsList(); $fixes = new \CodeReview\CodeFixer(); $title = elgg_echo('code_review:private_list:title'); $body = "<table class=\"elgg-table-alt\">"; $body .= "<tr>" . "<th><strong>" . elgg_echo('code_review:private_list:name') . "</strong></th>" . "<th><strong>" . elgg_echo('code_review:private_list:reason') . "</strong></th>" . "</tr>"; ksort($functions, SORT_STRING); foreach ($functions as $name => $data) { $fileLine = elgg_echo('code_review:private_list:file_line', array($data['file'], $data['line'])); $body .= "<tr><td><abbr title=\"{$fileLine}\">" . $data['name'] . "</abbr></td>" . "<td>" . elgg_echo('code_review:private_list:reason:' . $data['reason']) . "</td></tr>"; } $body .= '</table>'; echo elgg_view_module('featured', $title, $body, array('class' => 'mbl'));