function enterNode(Node $node)
 {
     switch (get_class($node)) {
         case Class_::class:
             $name = $node->namespacedName ? $node->namespacedName->toString() : "anonymous class";
             if ($name) {
                 $file = $this->index->getClassFile($name);
                 if ($file) {
                     $this->output->emitError(__CLASS__, $this->filename, $node->getLine(), BaseCheck::TYPE_PARSE_ERROR, "Class {$name} already exists in {$file}.");
                 } else {
                     $this->index->addClass($name, $node, $this->filename);
                 }
                 array_push($this->classStack, $node);
             }
             break;
         case Interface_::class:
             $name = $node->namespacedName->toString();
             $this->index->addInterface($name, $node, $this->filename);
             array_push($this->classStack, $node);
             break;
         case Function_::class:
             $name = $node->namespacedName->toString();
             $this->index->addFunction($name, $node, $this->filename);
             break;
         case \PhpParser\Node\Const_::class:
             if (count($this->classStack) == 0) {
                 $defineName = strval($node->name);
                 $this->index->addDefine($defineName, $node, $this->filename);
             }
             break;
         case FuncCall::class:
             if ($node->name instanceof Node\Name) {
                 $name = strval($node->name);
                 if (strcasecmp($name, 'define') == 0 && count($node->args) >= 1 && $node->args[0]->value instanceof Node\Scalar\String_) {
                     $defineName = $node->args[0]->value->value;
                     $this->index->addDefine($defineName, $node, $this->filename);
                 }
             }
             break;
         case Trait_::class:
             $name = $node->namespacedName->toString();
             $this->index->addTrait($name, $node, $this->filename);
             array_push($this->classStack, $node);
             break;
     }
     if ($node instanceof ClassMethod && property_exists($node, 'namespacedName') && count($this->classStack) > 0) {
         $classNode = $this->classStack[count($this->classStack) - 1];
         $className = $classNode->namespacedName->toString();
         $this->index->addMethod($className, $node->name, $node);
     }
     return null;
 }
 function run(Config $config, OutputInterface $output)
 {
     $configArr = $config->getConfigArray();
     $indexPaths = $configArr['index'];
     foreach ($indexPaths as $directory) {
         $tmpDirectory = strpos($directory, "/") === 0 ? $directory : $config->getBasePath() . "/" . $directory;
         $output->outputVerbose("Indexing Directory: " . $tmpDirectory . "\n");
         $it = new \RecursiveDirectoryIterator($tmpDirectory, \FilesystemIterator::SKIP_DOTS);
         $it2 = new \RecursiveIteratorIterator($it);
         $this->index($config, $output, $it2);
     }
     $it = new \RecursiveDirectoryIterator(dirname(__DIR__) . "/ExtraStubs");
     $it2 = new \RecursiveIteratorIterator($it);
     $this->index($config, $output, $it2, true);
     /*
     
     		$it = new \RecursiveDirectoryIterator(dirname(dirname(__DIR__)) . "/vendor/phpstubs/phpstubs/res");
     		$it2 = new \RecursiveIteratorIterator($it);
     		$this->index($config, $it2, true);
     */
 }
 function run(Config $config, OutputInterface $output)
 {
     $basePath = $config->getBasePath();
     $toProcess = [];
     $configArray = $config->getConfigArray();
     foreach ($configArray['test'] as $directory) {
         $directory = $basePath . "/" . $directory;
         $output->outputVerbose("Directory: {$directory}\n");
         $it = new \RecursiveDirectoryIterator($directory, \FilesystemIterator::SKIP_DOTS);
         $it2 = new \RecursiveIteratorIterator($it);
         $this->getPhase2Files($config, $output, $it2, $toProcess);
     }
     sort($toProcess);
     // First we split up the files by partition.
     // If we're running multiple child processes, then we'll split the list again.
     $groupSize = intval(count($toProcess) / $config->getPartitions());
     $toProcess = $config->getPartitionNumber() == $config->getPartitions() ? array_slice($toProcess, $groupSize * ($config->getPartitionNumber() - 1)) : array_slice($toProcess, $groupSize * ($config->getPartitionNumber() - 1), $groupSize);
     $output->outputVerbose("Analyzing " . count($toProcess) . " files\n");
     if ($config->getProcessCount() > 1) {
         return $this->runChildProcesses($config, $output, $toProcess);
     } else {
         return $this->phase2($config, $output, $toProcess);
     }
 }
Example #4
0
 function incTests()
 {
     $this->doc->incTests();
 }