public function setAnalyzer(Analyzer $analyzer) { $this->logger = $analyzer->logger; $this->registry = $registry = $analyzer->getTypeRegistry(); $this->reverseInterpreter = new SemanticReverseAbstractInterpreter($registry); $this->functionInterpreter = new ChainableFunctionInterpreter(array(new CoreFunctionInterpreter($registry), new ArrayFunctionInterpreter($registry))); $this->methodInterpreter = new ChainableMethodInterpreter(array(new CoreMethodInterpreter($registry), new PhpUnitMethodInterpreter($registry))); $this->commentParser = new \Scrutinizer\PhpAnalyzer\PhpParser\DocCommentParser($registry); $this->commentParser->setLogger($analyzer->logger); $this->scopeCreator = new TypedScopeCreator($registry); }
protected function execute(InputInterface $input, OutputInterface $output) { $dir = $input->getArgument('dir'); if (extension_loaded('xdebug')) { $output->writeln('<error>It is highly recommended to disable the XDebug extension before invoking this command.</error>'); } $output->writeln('Scanning directory <info>' . $dir . '</info>'); $files = FileCollection::createFromDirectory($dir, '*.php', array('paths' => $input->getOption('include-pattern'), 'excluded_paths' => $input->getOption('exclude-pattern'))); $output->writeln(sprintf('found <info>%d files</info>', count($files))); if (count($files) > 100) { $output->writeln('<comment>Caution: You are trying to scan a lot of files; this might be slow. For bigger libraries, consider setting up a dedicated platform or using scrutinizer-ci.com.</comment>'); } $output->writeln('Starting analysis...'); $analyzer = Analyzer::create(TestUtils::createTestEntityManager()); $analyzer->setLogger(new OutputLogger($output, $input->getOption('verbose'))); $analyzer->analyze($files); if ($input->getOption('filter-pattern')) { $files = $files->filter($input->getOption('filter-pattern')); } switch ($input->getOption('format')) { case 'plain': $formatter = new OutputFormatter\TextFormatter(); break; default: $formatter = new OutputFormatter\SerializerFormatter($input->getOption('output-file'), $input->getOption('format')); break; } $formatter->write($output, $files); }
protected function setUp() { $this->em = TestUtils::createTestEntityManager(); $this->analyzer = \Scrutinizer\PhpAnalyzer\Analyzer::create($this->em); $defaultConfig = array(); foreach ($this->analyzer->getPassConfig()->getConfigurablePasses() as $pass) { $node = $pass->getConfiguration()->buildTree(); assert($node instanceof ArrayNode); if (array_key_exists('enabled', $node->getChildren())) { $defaultConfig[$node->getName()]['enabled'] = true; } } // Some manual changes. $defaultConfig['suspicious_code']['overriding_parameter'] = true; $defaultConfig['verify_php_doc_comments'] = array_merge($defaultConfig['verify_php_doc_comments'], array('suggest_more_specific_types' => true, 'ask_for_return_if_not_inferrable' => true, 'ask_for_param_type_annotation' => true)); $this->analyzer->setConfigurationValues($defaultConfig); }
protected function execute(InputInterface $input, OutputInterface $output) { if (is_file($dbFile = __DIR__ . '/../../../../res/test_database.sqlite')) { unlink($dbFile); } $em = TestUtils::createTestEntityManager(); $tool = new SchemaTool($em); $tool->createSchema($em->getMetadataFactory()->getAllMetadata()); $analyzer = Analyzer::create($em, PassConfig::createForTypeScanning()); $packageScanner = new PackageScanner($analyzer); $packageScanner->setLogger(new OutputLogger($output, $input->getOption('verbose'))); $package = new Package('PHP'); $packageVersion = $package->createVersion('5.3'); $packageVersion->setUuid(uniqid(mt_rand(), true)); $packageScanner->scanDirectory($packageVersion, __DIR__ . '/../../../../res/php-5.3-core-api'); $output->writeln('Files scanned.'); $output->write('Persisting results... '); $em->persist($package); $em->flush(); $output->writeln('Done'); }
public function setAnalyzer(Analyzer $analyzer) { $this->analyzer = $analyzer; $this->typeRegistry = $analyzer->getTypeRegistry(); }
public function setAnalyzer(Analyzer $analyzer) { $this->registry = $analyzer->getTypeRegistry(); $this->parser = new DocCommentParser($this->registry); }
protected function getAnalyzer() { return Analyzer::create(TestUtils::createTestEntityManager(), PassConfig::createForTypeScanning()); }
public function setAnalyzer(\Scrutinizer\PhpAnalyzer\Analyzer $analyzer) { $this->analyzer = $analyzer; $this->registry = $analyzer->getTypeRegistry(); }
protected function getAnalyzer() { return Analyzer::create(TestUtils::createTestEntityManager(), $this->getPassConfig()); }