diff --git a/lang/en/local_moodlecheck.php b/lang/en/local_moodlecheck.php
index 1566f5a..d7531eb 100644
--- a/lang/en/local_moodlecheck.php
+++ b/lang/en/local_moodlecheck.php
@@ -37,11 +37,6 @@
$string['error_emptynophpfile'] = 'The file is empty or doesn\'t contain PHP code. Skipped.';
-$string['rule_filephpdocpresent'] = 'File-level phpdocs block is present';
-$string['error_filephpdocpresent'] = 'File-level phpdocs block is not found';
-
-$string['rule_classesdocumented'] = 'All classes are documented';
-$string['error_classesdocumented'] = 'Class {$a->class} is not documented';
$string['rule_functionsdocumented'] = 'All functions are documented';
$string['error_functionsdocumented'] = 'Function {$a->function} is not documented';
$string['rule_variablesdocumented'] = 'All variables are documented';
diff --git a/rules/phpdocs_basic.php b/rules/phpdocs_basic.php
index a235a13..524003e 100644
--- a/rules/phpdocs_basic.php
+++ b/rules/phpdocs_basic.php
@@ -24,8 +24,6 @@
defined('MOODLE_INTERNAL') || die;
-local_moodlecheck_registry::add_rule('filephpdocpresent')->set_callback('local_moodlecheck_filephpdocpresent');
-local_moodlecheck_registry::add_rule('classesdocumented')->set_callback('local_moodlecheck_classesdocumented');
local_moodlecheck_registry::add_rule('functionsdocumented')->set_callback('local_moodlecheck_functionsdocumented');
local_moodlecheck_registry::add_rule('variablesdocumented')->set_callback('local_moodlecheck_variablesdocumented');
local_moodlecheck_registry::add_rule('constsdocumented')->set_callback('local_moodlecheck_constsdocumented');
@@ -47,47 +45,6 @@
local_moodlecheck_registry::add_rule('phpdocsuncurlyinlinetag')->set_callback('local_moodlecheck_phpdocsuncurlyinlinetag');
local_moodlecheck_registry::add_rule('phpdoccontentsinlinetag')->set_callback('local_moodlecheck_phpdoccontentsinlinetag');
-/**
- * Checks if file-level phpdocs block is present
- *
- * @param local_moodlecheck_file $file
- * @return array of found errors
- */
-function local_moodlecheck_filephpdocpresent(local_moodlecheck_file $file) {
- // This rule doesn't apply if the file is 1-artifact file (see #66).
- $artifacts = $file->get_artifacts();
- if (count($artifacts[T_CLASS]) + count($artifacts[T_INTERFACE]) + count($artifacts[T_TRAIT]) === 1) {
- return [];
- }
- if ($file->find_file_phpdocs() === false) {
- $tokens = &$file->get_tokens();
- for ($i = 0; $i < 90; $i++) {
- if (isset($tokens[$i]) && !in_array($tokens[$i][0], [T_OPEN_TAG, T_WHITESPACE, T_COMMENT])) {
- return [['line' => $file->get_line_number($i)]];
- }
- }
- // For some reason we cound not find the line number.
- return [['line' => '']];
- }
- return [];
-}
-
-/**
- * Checks if all classes have phpdocs blocks
- *
- * @param local_moodlecheck_file $file
- * @return array of found errors
- */
-function local_moodlecheck_classesdocumented(local_moodlecheck_file $file) {
- $errors = [];
- foreach ($file->get_classes() as $class) {
- if ($class->phpdocs === false) {
- $errors[] = ['class' => $class->name, 'line' => $file->get_line_number($class->boundaries[0])];
- }
- }
- return $errors;
-}
-
/**
* Checks if all functions have phpdocs blocks.
*
diff --git a/tests/moodlecheck_rules_test.php b/tests/moodlecheck_rules_test.php
index eaf9253..adc2abb 100644
--- a/tests/moodlecheck_rules_test.php
+++ b/tests/moodlecheck_rules_test.php
@@ -71,51 +71,6 @@ public function test_constantclass(): void {
// TODO: Change to DOMNodeList::count() when php71 support is gone.
$this->assertSame(0, $found->length);
-
- // Also verify that contents do not include any problem with line 42 / classesdocumented. Use simple string matching here.
- $this->assertStringNotContainsString('line="42"', $result);
- $this->assertStringNotContainsString('classesdocumented', $result);
- }
-
- /**
- * Assert that the file block is required for old files, and not for 1-artifact ones.
- *
- * @covers ::local_moodlecheck_filephpdocpresent
- */
- public function test_file_block_required(): void {
- global $PAGE;
-
- $output = $PAGE->get_renderer('local_moodlecheck');
-
- // A file with multiple classes, require the file phpdoc block.
- $path = new local_moodlecheck_path('local/moodlecheck/tests/fixtures/phpdoc_file_required_yes1.php', null);
- $result = $output->display_path($path, 'xml');
- $this->assertStringContainsString('File-level phpdocs block is not found', $result);
-
- // A file without any class (library-like), require the file phpdoc block.
- $path = new local_moodlecheck_path('local/moodlecheck/tests/fixtures/phpdoc_file_required_yes2.php', null);
- $result = $output->display_path($path, 'xml');
- $this->assertStringContainsString('File-level phpdocs block is not found', $result);
-
- // A file with one interface and one trait, require the file phpdoc block.
- $path = new local_moodlecheck_path('local/moodlecheck/tests/fixtures/phpdoc_file_required_yes3.php', null);
- $result = $output->display_path($path, 'xml');
- $this->assertStringContainsString('File-level phpdocs block is not found', $result);
-
- // A file with only one class, do not require the file phpdoc block.
- $path = new local_moodlecheck_path('local/moodlecheck/tests/fixtures/phpdoc_file_required_no1.php', null);
- $result = $output->display_path($path, 'xml');
- $this->assertStringNotContainsString('File-level phpdocs block is not found', $result);
-
- // A file with only one interface, do not require the file phpdoc block.
- $path = new local_moodlecheck_path('local/moodlecheck/tests/fixtures/phpdoc_file_required_no2.php', null);
- $result = $output->display_path($path, 'xml');
- $this->assertStringNotContainsString('File-level phpdocs block is not found', $result);
-
- // A file with only one trait, do not require the file phpdoc block.
- $path = new local_moodlecheck_path('local/moodlecheck/tests/fixtures/phpdoc_file_required_no3.php', null);
- $result = $output->display_path($path, 'xml');
- $this->assertStringNotContainsString('File-level phpdocs block is not found', $result);
}
/**
@@ -361,76 +316,6 @@ public function test_phpdoc_tags_inline(): void {
$this->assertStringNotContainsString('ba8by}', $result);
}
- /**
- * Verify that anonymous classes do not require phpdoc class blocks.
- *
- * @dataProvider anonymous_class_provider
- * @param string $path
- * @param bool $expectclassesdocumentedfail Whether the
- *
- * @covers \local_moodlecheck_file::get_artifacts
- */
- public function test_phpdoc_anonymous_class_docblock(string $path, bool $expectclassesdocumentedfail): void {
- global $PAGE;
-
- $output = $PAGE->get_renderer('local_moodlecheck');
- $checkpath = new local_moodlecheck_path($path, null);
- $result = $output->display_path($checkpath, 'xml');
-
- if ($expectclassesdocumentedfail) {
- $this->assertStringContainsString('classesdocumented', $result);
- } else {
- $this->assertStringNotContainsString('classesdocumented', $result);
- }
- }
-
- /**
- * Data provider for anonymous classes tests.
- *
- * @return array
- */
- public static function anonymous_class_provider(): array {
- $rootpath = 'local/moodlecheck/tests/fixtures/anonymous';
- return [
- 'return new class {' => [
- "{$rootpath}/anonymous.php",
- false,
- ],
- 'return new class extends parentclass {' => [
- "{$rootpath}/extends.php",
- false,
- ],
- 'return new class implements someinterface {' => [
- "{$rootpath}/implements.php",
- false,
- ],
- 'return new class extends parentclass implements someinterface {' => [
- "{$rootpath}/extendsandimplements.php",
- false,
- ],
- 'return new class (with params) {' => [
- "{$rootpath}/anonymous_with_params.php",
- false,
- ],
- 'return new class (with params) extends parentclass {' => [
- "{$rootpath}/extends_with_params.php",
- false,
- ],
- 'return new class (with params) implements someinterface {' => [
- "{$rootpath}/implements_with_params.php",
- false,
- ],
- '$value = new class {' => [
- "{$rootpath}/assigned.php",
- false,
- ],
- 'class someclass extends parentclass {' => [
- "{$rootpath}/named.php",
- true,
- ],
- ];
- }
-
/**
* Verify that empty files and files without PHP aren't processed
*
@@ -613,7 +498,6 @@ public function test_text_format_errors_and_warnings(): void {
$result = $output->display_path($path, 'text');
$this->assertStringContainsString('tests/fixtures/error_and_warning.php', $result);
- $this->assertStringContainsString('11: Class someclass is not documented (error)', $result);
$this->assertStringContainsString('12: Function someclass::somefunc is not documented (warning)', $result);
}
@@ -631,7 +515,6 @@ public function test_html_format_errors_and_warnings(): void {
$result = $output->display_path($path, 'html');
$this->assertStringContainsString('tests/fixtures/error_and_warning.php', $result);
- $this->assertStringContainsString('11: Class someclass is not documented (error)', $result);
$this->assertStringContainsString('12: Function someclass::somefunc is not documented (warning)', $result);
}
}