public function setAnalyzer(Analyzer $analyzer)
 {
     parent::setAnalyzer($analyzer);
     $paramParser = new ParameterParser($this->typeRegistry);
     $this->commentParser = new DocCommentParser($this->typeRegistry);
     $this->commentParser->setLogger($analyzer->logger);
     $this->classParser = new ClassParser($this->typeRegistry, $paramParser, $this->commentParser, $analyzer->logger);
     $this->classFiles = new \SplObjectStorage();
     $this->functionParser = new FunctionParser($this->typeRegistry, $paramParser);
 }
 public function analyze(File $file)
 {
     if (!$file instanceof PhpFile) {
         return;
     }
     $this->phpFile = $file;
     if ($this->analyzeAstFirst()) {
         parent::analyze($file);
         $this->stream->setCode($file->getContent());
         $this->analyzeStream();
     } else {
         $this->stream->setCode($file->getContent());
         $this->analyzeStream();
         parent::analyze($file);
     }
 }
 public function analyze(File $file)
 {
     if (!$file instanceof PhpFile) {
         return;
     }
     $this->codingStyle = $this->analyzer->getPhpCodingStyle();
     $this->tokens = token_get_all($content = $file->getContent());
     $this->i = -1;
     $this->lines = explode("\n", $content);
     $this->curLine = 1;
     parent::analyze($file);
     while ($this->next()) {
         $this->checkWhitespace();
         if (T_OPEN_TAG === $this->token[0] && '<?' === $this->token[1] && !$this->codingStyle->allowShortPhpOpenTag) {
             $this->addComment(1, 'Please do not use the short-opening tag, but "<?php" instead.');
             continue;
         }
     }
     // Check that file ends with a linefeed character
     if ("\n" !== substr($content, -1)) {
         $this->addComment(count($this->lines), 'Please add a linefeed (\\n) at the end of the file.');
     }
     $foundTabs = $foundLinefeed = $foundTrailingWhitespace = false;
     foreach ($this->lines as $i => $line) {
         // Check that there are no tabs inside the file.
         if (!$foundTabs && preg_match('/^(?: )*\\t/', $line)) {
             $this->addComment($i + 1, 'Please do not use tabs for indentation, but 4 spaces for each tab.');
             // Assume that the users fixes all further occurrences of tabs.
             $foundTabs = true;
             continue;
         }
         // Check for correct line-ending character
         if (!$foundLinefeed && "\r" === substr($line, -1)) {
             $this->addComment($i + 1, 'Please do not use the line-ending (\\r\\n), but only \\n (0x0A).');
             // Assume that the user fixed all further occurrences.
             $foundLinefeed = true;
             continue;
         }
         // Check for trailing white-space
         if (!$foundTrailingWhitespace && preg_match('/\\s+$/', $line)) {
             $this->addComment($i + 1, 'Please do not add trailing whitespace.');
             $foundTrailingWhitespace = true;
             continue;
         }
     }
 }
 public function setAnalyzer(Analyzer $analyzer)
 {
     parent::setAnalyzer($analyzer);
     $this->typeChecker = new TypeChecker($this->typeRegistry);
     $this->argumentChecker = new OverloadedCoreFunctionChecker($this->typeRegistry, $this->typeChecker);
     $this->argumentChecker->append(new PhpUnitAssertionChecker($this->typeRegistry, $this->typeChecker));
     $this->argumentChecker->append(new DefaultArgumentChecker($this->typeRegistry, $this->typeChecker));
 }
 public function setAnalyzer(Analyzer $analyzer)
 {
     parent::setAnalyzer($analyzer);
     $this->parser = new DocCommentParser($this->typeRegistry);
 }