Skip to content

Commit 7bffe4d

Browse files
Remove variablesdocumented (#135)
Replaced by moodlehq/moodle-cs#121 Co-authored-by: Eloy Lafuente <[email protected]>
1 parent 5398c9c commit 7bffe4d

File tree

4 files changed

+0
-143
lines changed

4 files changed

+0
-143
lines changed

lang/en/local_moodlecheck.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@
3737

3838
$string['error_emptynophpfile'] = 'The file is empty or doesn\'t contain PHP code. Skipped.';
3939

40-
$string['rule_variablesdocumented'] = 'All variables are documented';
41-
$string['error_variablesdocumented'] = 'Variable <b>{$a->variable}</b> is not documented';
4240
$string['rule_constsdocumented'] = 'All constants are documented';
4341
$string['error_constsdocumented'] = 'Constant <b>{$a->object}</b> is not documented';
4442
$string['rule_definesdocumented'] = 'All define statements are documented';
@@ -65,9 +63,6 @@
6563
$string['error_functionarguments'] = 'Phpdocs for function <b>{$a->function}</b> has incomplete parameters list';
6664
$string['rule_functionarguments'] = 'Phpdocs for functions properly define all parameters';
6765

68-
$string['error_variableshasvar'] = 'Phpdocs for variable <b>{$a->variable}</b> does not contain @var or incorrect';
69-
$string['rule_variableshasvar'] = 'Phpdocs for variables contain @var with variable type and name';
70-
7166
$string['error_definedoccorrect'] = 'Phpdocs for define statement must start with constant name and dash: <b>{$a->object}</b>';
7267
$string['rule_definedoccorrect'] = 'Check syntax for define statement';
7368

rules/phpdocs_basic.php

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -24,35 +24,17 @@
2424

2525
defined('MOODLE_INTERNAL') || die;
2626

27-
local_moodlecheck_registry::add_rule('variablesdocumented')->set_callback('local_moodlecheck_variablesdocumented');
2827
local_moodlecheck_registry::add_rule('constsdocumented')->set_callback('local_moodlecheck_constsdocumented');
2928
local_moodlecheck_registry::add_rule('definesdocumented')->set_callback('local_moodlecheck_definesdocumented');
3029
local_moodlecheck_registry::add_rule('noinlinephpdocs')->set_callback('local_moodlecheck_noinlinephpdocs');
3130
local_moodlecheck_registry::add_rule('phpdocsfistline')->set_callback('local_moodlecheck_phpdocsfistline');
3231
local_moodlecheck_registry::add_rule('functiondescription')->set_callback('local_moodlecheck_functiondescription');
3332
local_moodlecheck_registry::add_rule('functionarguments')->set_callback('local_moodlecheck_functionarguments');
34-
local_moodlecheck_registry::add_rule('variableshasvar')->set_callback('local_moodlecheck_variableshasvar');
3533
local_moodlecheck_registry::add_rule('definedoccorrect')->set_callback('local_moodlecheck_definedoccorrect');
3634
local_moodlecheck_registry::add_rule('phpdocsinvalidinlinetag')->set_callback('local_moodlecheck_phpdocsinvalidinlinetag');
3735
local_moodlecheck_registry::add_rule('phpdocsuncurlyinlinetag')->set_callback('local_moodlecheck_phpdocsuncurlyinlinetag');
3836
local_moodlecheck_registry::add_rule('phpdoccontentsinlinetag')->set_callback('local_moodlecheck_phpdoccontentsinlinetag');
3937

40-
/**
41-
* Checks if all variables have phpdocs blocks
42-
*
43-
* @param local_moodlecheck_file $file
44-
* @return array of found errors
45-
*/
46-
function local_moodlecheck_variablesdocumented(local_moodlecheck_file $file) {
47-
$errors = [];
48-
foreach ($file->get_variables() as $variable) {
49-
if ($variable->phpdocs === false) {
50-
$errors[] = ['variable' => $variable->fullname, 'line' => $file->get_line_number($variable->tid)];
51-
}
52-
}
53-
return $errors;
54-
}
55-
5638
/**
5739
* Checks if all constants have phpdocs blocks
5840
*
@@ -340,27 +322,6 @@ function($type) {
340322
return implode('|', $types);
341323
}
342324

343-
/**
344-
* Checks that all variables have proper \var token in phpdoc block
345-
*
346-
* @param local_moodlecheck_file $file
347-
* @return array of found errors
348-
*/
349-
function local_moodlecheck_variableshasvar(local_moodlecheck_file $file) {
350-
$errors = [];
351-
foreach ($file->get_variables() as $variable) {
352-
if ($variable->phpdocs !== false) {
353-
$documentedvars = $variable->phpdocs->get_params('var', 2);
354-
if (!count($documentedvars) || $documentedvars[0][0] == 'type') {
355-
$errors[] = [
356-
'line' => $variable->phpdocs->get_line_number($file, '@var'),
357-
'variable' => $variable->fullname, ];
358-
}
359-
}
360-
}
361-
return $errors;
362-
}
363-
364325
/**
365326
* Checks that all define statement have constant name in phpdoc block
366327
*

tests/fixtures/phpdoc_properties.php

Lines changed: 0 additions & 56 deletions
This file was deleted.

tests/moodlecheck_rules_test.php

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -347,49 +347,6 @@ public function test_constsdocumented_ignore_uses(): void {
347347
$this->assertSame(0, $found->length);
348348
}
349349

350-
/**
351-
* Verify that `variablesdocumented` correctly detects PHPdoc on different kinds of properties.
352-
*
353-
* @covers ::local_moodlecheck_variablesdocumented
354-
* @covers \local_moodlecheck_file::get_variables
355-
*/
356-
public function test_variables_and_constants_documented(): void {
357-
$file = __DIR__ . "/fixtures/phpdoc_properties.php";
358-
359-
global $PAGE;
360-
$output = $PAGE->get_renderer('local_moodlecheck');
361-
$path = new local_moodlecheck_path($file, null);
362-
$result = $output->display_path($path, 'xml');
363-
364-
// Convert results to XML Object.
365-
$xmlresult = new \DOMDocument();
366-
$xmlresult->loadXML($result);
367-
368-
$xpath = new \DOMXpath($xmlresult);
369-
370-
// Verify that the undocumented variables are reported.
371-
372-
$found = $xpath->query('//file/error[@source="variablesdocumented"]');
373-
// TODO: Change to DOMNodeList::count() when php71 support is gone.
374-
$this->assertSame(4, $found->length);
375-
376-
// The PHPdocs of the other properties should be detected correctly.
377-
$this->assertStringContainsString('$undocumented1', $found->item(0)->getAttribute("message"));
378-
$this->assertStringContainsString('$undocumented2', $found->item(1)->getAttribute("message"));
379-
$this->assertStringContainsString('$undocumented3', $found->item(2)->getAttribute("message"));
380-
$this->assertStringContainsString('$undocumented4', $found->item(3)->getAttribute("message"));
381-
382-
// Verify that the undocumented constants are reported.
383-
384-
$found = $xpath->query('//file/error[@source="constsdocumented"]');
385-
// TODO: Change to DOMNodeList::count() when php71 support is gone.
386-
$this->assertSame(2, $found->length);
387-
388-
// The PHPdocs of the other properties should be detected correctly.
389-
$this->assertStringContainsString('UNDOCUMENTED_CONSTANT1', $found->item(0)->getAttribute("message"));
390-
$this->assertStringContainsString('UNDOCUMENTED_CONSTANT2', $found->item(1)->getAttribute("message"));
391-
}
392-
393350
/**
394351
* Verify that the text format shown information about the severity of the problem (error vs warning)
395352
*

0 commit comments

Comments
 (0)