/** * This method adds a violation to all reports for this violation type and * for the given <b>$node</b> instance. * * @param PHP_PMD_AbstractNode $node The node which has a violation of this * type. * @param array(string) $args Optional list of arguments that are * used to replace "{\d+}" placeholders in * the message text of this rule. * * @return void */ protected function addViolation(PHP_PMD_AbstractNode $node, array $args = array()) { $search = array(); $replace = array(); foreach ($args as $index => $value) { $search[] = '{' . $index . '}'; $replace[] = $value; } $message = str_replace($search, $replace, $this->message); $ruleViolation = new PHP_PMD_RuleViolation($this, $node, $message); $this->report->addRuleViolation($ruleViolation); }
/** * testIsEmptyReturnsFalseWhenAtLeastOneViolationExists * * @return void * @covers PHP_PMD_Report * @group phpmd * @group unittest */ public function testIsEmptyReturnsFalseWhenAtLeastOneViolationExists() { $report = new PHP_PMD_Report(); $report->addRuleViolation($this->getRuleViolationMock('foo.txt', 4, 5)); $this->assertFalse($report->isEmpty()); }