/**
  * @param FileInterface $file
  *
  * @throws \Phpbb\Epv\Tests\Exception\TestException
  */
 public function validateFile(FileInterface $file)
 {
     if (!$file instanceof ComposerFileInterface) {
         throw new TestException('This test expects a php type, but found something else.');
     }
     if (!$file->getJson() || !is_array($file->getJson())) {
         throw new TestException('Parsing composer file failed');
     }
     $this->file = $file;
     $this->validateName($file);
     $this->validateLicense($file);
     $this->validateVersion($file);
 }
Exemple #2
0
 public function __toString()
 {
     $file = '';
     if ($this->file != null) {
         $file = ' in ' . $this->file->getSaveFilename();
     }
     switch ($this->type) {
         case Output::NOTICE:
             return "<noticeb>Notice:</noticeb><notice> {$this->message}{$file}</notice>";
         case Output::WARNING:
             return "<warningb>Warning:</warningb><warning> {$this->message}{$file}</warning>";
         case Output::ERROR:
             return "<errorb>Error:</errorb><error> {$this->message}{$file}</error>";
         case Output::FATAL:
             return "<fatalb>Fatal error:</fatalb><fatal> {$this->message}{$file}</fatal>";
         case Output::DEBUG:
             return $this->message;
     }
 }
 /**
  * @param FileInterface $file
  *
  * @throws \Phpbb\Epv\Tests\Exception\TestException
  */
 public function validateFile(FileInterface $file)
 {
     if (!$file instanceof PHPFileInterface) {
         throw new TestException('This test expects a php type, but found something else.');
     }
     $this->file = $file;
     $eols = array_count_values(str_split(preg_replace("/[^\r\n]/", "", $file->getFile())));
     $eola = array_keys($eols, max($eols));
     $eol = implode("", $eola);
     if ($eol == "\n") {
         // Everything is good to go
         return;
     }
     if ($eol == "\r\n") {
         $this->addMessage(Output::FATAL, "Detected windows style newlines instead of UNIX newlines");
     }
     if ($eol == "\r") {
         $this->addMessage(Output::FATAL, "Detected carriage return instead of UNIX newlines");
     }
 }