/** * {@inheritdoc} */ public function addViolation(Node $node, AnalyzerInterface $detector) { $file = $node->getFilename(); if ($file) { $this->violations[$file][] = ['line_number' => $node->getLineNumber()]; } else { throw new \DomainException('Cannot record an issue violation from a detached node.'); } $this->addDetector($detector); return $this; }