コード例 #1
0
ファイル: DiffFilter.php プロジェクト: wouterj/docbot
 /**
  * @return int One of the result constants
  */
 public function handle(ConstraintViolationListInterface $constraintViolationList, Text $file)
 {
     $diff = null;
     if ($file instanceof File) {
         foreach ($this->diff as $d) {
             if (substr($d->getTo(), 2) === $file->getFilename()) {
                 $diff = $d;
                 break;
             }
         }
         if (null === $diff) {
             return Reporter::SUCCESS;
         }
     }
     foreach ($constraintViolationList as $offset => $violation) {
         /** @var ConstraintViolation $violation */
         $lineNumber = $this->getLineNumber($violation);
         foreach ($diff->getChunks() as $chunk) {
             if ($chunk->getEnd() > $lineNumber || $chunk->getEnd() + $chunk->getEndRange() < $lineNumber) {
                 $constraintViolationList->remove($offset);
             }
         }
     }
     return $this->reporter->handle($constraintViolationList, $file);
 }
コード例 #2
0
ファイル: SortReporter.php プロジェクト: wouterj/docbot
 /**
  * @return int One of the result constants
  */
 public function handle(ConstraintViolationListInterface $constraintViolationList, Text $file)
 {
     $constraintViolationList = iterator_to_array($constraintViolationList);
     $that = $this;
     usort($constraintViolationList, function (ConstraintViolation $a, ConstraintViolation $b) use($that) {
         $aNumber = $that->getLineNumber($a);
         $bNumber = $that->getLineNumber($b);
         if ($aNumber === $bNumber) {
             return 0;
         }
         return $aNumber > $bNumber ? 1 : -1;
     });
     return $this->reporter->handle($constraintViolationList, $file);
 }