Skip to content

Commit

Permalink
Require PHPMD 2.14+, fix process call, and allow tests to run on 8.1+
Browse files Browse the repository at this point in the history
  • Loading branch information
mrook committed Nov 6, 2023
1 parent 29ea57a commit d2ee9b2
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
"pear/versioncontrol_git": "dev-master",
"pear/versioncontrol_svn": "^0.7.0",
"phing/phing-composer-configurator": "dev-master",
"phpmd/phpmd": "^2.10",
"phpmd/phpmd": "^2.14",
"phpstan/phpstan": "^0.12.87 || ^1.0",
"phpunit/phpunit": "^9.5.10",
"psr/http-message": "^1.0",
Expand Down
2 changes: 1 addition & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 14 additions & 5 deletions src/Phing/Task/Ext/Analyzer/Phpmd/PHPMDTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public function setMinimumPriority($minimumPriority)
*
* @param string $ruleSetFileNames Comma-separated string of rule-set filenames or identifier.
*/
public function setRulesets($ruleSetFileNames)
public function setRulesets(string $ruleSetFileNames)
{
$this->rulesets = $ruleSetFileNames;
}
Expand Down Expand Up @@ -285,6 +285,17 @@ protected function getFilesToParse()
return $filesToParse;
}

/**
* @return \PHPMD\RuleSet[]
*/
protected function getRuleSets(): array
{
$ruleSetFactory = new RuleSetFactory();
$ruleSetFactory->setMinimumPriority($this->minimumPriority);
$rulesets = $ruleSetFactory->createRuleSets($this->rulesets);
return $rulesets;
}

/**
* Executes PHPMD against PhingFile or a FileSet
*
Expand Down Expand Up @@ -327,9 +338,7 @@ public function main()
$this->cache = null; // cache not compatible to old version
}

// Create a rule set factory
$ruleSetFactory = new RuleSetFactory();
$ruleSetFactory->setMinimumPriority($this->minimumPriority);
$rulesets = $this->getRuleSets();

/**
* @var PHPMD $phpmd
Expand All @@ -346,7 +355,7 @@ public function main()
$this->log('Processing files...');

$report = new Report();
$phpmd->processFiles($inputPath, $this->rulesets, $reportRenderers, $ruleSetFactory, $report);
$phpmd->processFiles($inputPath, $this->ignorePatterns, $reportRenderers, $rulesets, $report);

if ($this->cache) {
$this->cache->commit();
Expand Down
9 changes: 0 additions & 9 deletions tests/Phing/Test/Task/Ext/Analyzer/PHPMDTaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ public function setUp(): void
$this->configureProject(PHING_TEST_BASE . '/etc/tasks/ext/phpmd/build.xml');
}

/**
* @requires PHP < 8.1
*/
public function testReportText(): void
{
$this->executeTarget(__FUNCTION__);
Expand All @@ -46,9 +43,6 @@ public function testReportText(): void
unlink(PHING_TEST_BASE . '/etc/tasks/ext/phpmd/phpmd-report.txt');
}

/**
* @requires PHP < 8.1
*/
public function testReportHtml(): void
{
$this->executeTarget(__FUNCTION__);
Expand All @@ -58,9 +52,6 @@ public function testReportHtml(): void
unlink(PHING_TEST_BASE . '/etc/tasks/ext/phpmd/phpmd-report.html');
}

/**
* @requires PHP < 8.1
*/
public function testReportXml(): void
{
$this->executeTarget(__FUNCTION__);
Expand Down

0 comments on commit d2ee9b2

Please sign in to comment.