示例#1
0
 /** @inheritdoc */
 public function generate(array $replacements, $autoloader)
 {
     ReflectionEngine::init(new Locator($autoloader));
     foreach ($replacements as $replacement) {
         $fullPath = $this->vendorDir . '/' . $replacement['package'] . '/proxy/' . str_replace('\\', '/', $replacement['originalFullyQualifiedType']) . ".php";
         $this->filesystem->put($fullPath, $this->buildClass($replacement));
     }
 }
<?php

/**
 * Parser Reflection API
 *
 * @copyright Copyright 2015, Lisachenko Alexander <*****@*****.**>
 *
 * This source file is subject to the license that is bundled
 * with this source code in the file LICENSE.
 */
use Go\ParserReflection\Locator\ComposerLocator;
use Go\ParserReflection\ReflectionEngine;
/**
 * This file is used for automatic configuration of Go\ParserReflection\ReflectionEngine class
 */
ReflectionEngine::init(new ComposerLocator());
    /**
     * Refreshes database.
     *
     * @return void
     * @throws \LogicException When "$this->io" wasn't set upfront.
     */
    public function refresh()
    {
        if (!isset($this->io)) {
            throw new \LogicException('The "$this->io" must be set prior to calling "$this->refresh()".');
        }
        //ReflectionEngine::$maximumCachedFiles = 10;
        ReflectionEngine::init($this->detectClassLocator());
        $sql = 'UPDATE Files
				SET Found = 0';
        $this->db->perform($sql);
        $files = array();
        $this->io->write('Searching for files ... ');
        foreach ($this->getFinders() as $finder) {
            $files = array_merge($files, array_keys(iterator_to_array($finder)));
        }
        $file_count = count($files);
        $this->io->writeln(array('<info>' . $file_count . ' found</info>', ''));
        $progress_bar = $this->io->createProgressBar($file_count + 2);
        $progress_bar->setMessage('');
        $progress_bar->setFormat('%message%' . PHP_EOL . '%current%/%max% [%bar%] <info>%percent:3s%%</info> %elapsed:6s%/%estimated:-6s% <info>%memory:-10s%</info>');
        $progress_bar->start();
        foreach ($files as $file) {
            $progress_bar->setMessage('Processing File: <info>' . $this->removeProjectPath($file) . '</info>');
            $progress_bar->display();
            $this->processFile($file);
            $progress_bar->advance();
        }
        $sql = 'SELECT Id
				FROM Files
				WHERE Found = 0';
        $deleted_files = $this->db->fetchCol($sql);
        if ($deleted_files) {
            $progress_bar->setMessage('Deleting Files ...');
            $progress_bar->display();
            $sql = 'SELECT Id
					FROM Classes
					WHERE FileId IN (:file_ids)';
            $deleted_classes = $this->db->fetchCol($sql, array('file_ids' => $deleted_files));
            foreach ($deleted_classes as $deleted_class_id) {
                $this->deleteClass($deleted_class_id);
            }
            $progress_bar->advance();
        }
        $progress_bar->setMessage('Processing Class Relations ...');
        $progress_bar->display();
        $this->processClassRawRelations();
        $progress_bar->advance();
        $progress_bar->finish();
        $progress_bar->clear();
    }
示例#4
0
 /**
  * This method is called before the first test of this test class is run.
  *
  * @since Method available since Release 3.4.0
  */
 public static function setUpBeforeClass()
 {
     ReflectionEngine::init(new ComposerLocator());
 }