Exemplo n.º 1
0
 public function __construct(Nette\Loaders\RobotLoader $robotLoader)
 {
     $classes = $robotLoader->getIndexedClasses();
     foreach ($classes as $class => $file) {
         if (class_exists($class)) {
             $reflection = new \Nette\Reflection\ClassType($class);
             if ($reflection->implementsInterface('Tatami\\Modules\\IModule')) {
                 if (!($reflection->isAbstract() or $reflection->isInterface())) {
                     $this->modules[] = $this->parseModuleName($reflection->getShortName());
                 }
             }
             if ($reflection->isSubclassOf('Tatami\\Presenters\\BackendPresenter')) {
                 $moduleName = $this->parseModuleName($reflection->getNamespaceName());
                 $presenterName = $this->parsePresenterName($reflection->getShortName());
                 $this->presenters[$moduleName][] = $presenterName;
                 $methods = $reflection->getMethods(ReflectionMethod::IS_PUBLIC);
                 foreach ($methods as $method) {
                     if (Strings::match($method->name, '/action/') or Strings::match($method->name, '/render/')) {
                         $this->actions[$presenterName][] = $this->parseActionName($method->name);
                     }
                 }
             }
             unset($reflection);
         }
     }
 }
Exemplo n.º 2
0
 /**
  * Constructor, does all this beautiful magic, loads all libs
  * registers all sorts of funky hooks, checks stuff and so on.
  */
 public function __construct()
 {
     // nette, nope, we're not going without you brother
     if (!defined('NETTE')) {
         require_once 'libs/Nette/Nette.min.php';
     }
     // If debugging is the process of removing bugs, then programming must be the process of putting them in. - Edsger W. Dijkstra
     //\Nette\Diagnostics\Debugger::$productionMode = FALSE;
     //\Nette\Diagnostics\Debugger::enable();
     // required libs
     $robotLoader = new \Nette\Loaders\RobotLoader();
     $robotLoader->addDirectory(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'libs' . DIRECTORY_SEPARATOR);
     $robotLoader->setCacheStorage(new \Nette\Caching\Storages\MemoryStorage());
     $robotLoader->register();
     // cosntants define
     define('SUBSCRIBE_KEY', 'simpleSubscribe');
     define('SUBSCRIBE_CRON', 'simple_subscribe_cron');
     define('SUBSCRIBE_HOME_URL', get_option('siteurl'));
     define('SUBSCRIBE_FOLDER', plugins_url(NULL, __FILE__));
     define('SUBSCRIBE_ASSETS', SUBSCRIBE_FOLDER . '/assets/');
     define('SUBSCRIBE_TEMPLATES', dirname(__FILE__) . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR);
     define('SUBSCRIBE_API_URL', SUBSCRIBE_HOME_URL . '/' . '?' . SUBSCRIBE_KEY);
     // init
     add_action('init', array($this, 'init'));
     //add_action('admin_init', array($this, 'on_plugin_activated_redirect') );
     // widgets + shortcodes
     \SimpleSubscribe\Widgets::register();
     \SimpleSubscribe\Shortcodes::register();
     // settings
     $this->settings = new \SimpleSubscribe\Settings(SUBSCRIBE_KEY);
     $this->settingsAll = $this->settings->getSettings();
 }
Exemplo n.º 3
0
 /**
  * Find test suits to run
  * 
  * @param string $folder Where to look
  * @return string[]
  */
 protected function findSuits($folder)
 {
     $suits = [];
     $robot = new \Nette\Loaders\RobotLoader();
     $robot->setCacheStorage(new \Nette\Caching\Storages\DevNullStorage());
     $robot->addDirectory($folder);
     $robot->acceptFiles = "*.phpt";
     $robot->rebuild();
     $robot->register();
     $classes = $robot->getIndexedClasses();
     foreach ($classes as $class => $file) {
         $rc = new \Nette\Reflection\ClassType($class);
         if (!$rc->isAbstract() and $rc->isSubclassOf(TestCase::class)) {
             $suits[] = [$rc->getName(), $file];
         }
     }
     return $suits;
 }
 /**
  * @return Nette\Loaders\RobotLoader
  */
 public function createServiceRobotLoader()
 {
     $service = new Nette\Loaders\RobotLoader();
     $service->setCacheStorage($this->getService('cacheStorage'));
     $service->addDirectory('/home/fuca/Projects/www/sportsclub/tests/../vendor/others');
     $service->addDirectory('/home/fuca/Projects/www/sportsclub/tests');
     $service->register();
     return $service;
 }
Exemplo n.º 5
0
<?php

define('SRC_DIR', __DIR__ . '/../src/');
define('DISABLE_AUTOLOAD', true);
@mkdir(__DIR__ . "/log");
@mkdir(__DIR__ . "/../tmp");
require_once __DIR__ . '/../vendor/autoload.php';
if (file_exists(__DIR__ . '/environment.php')) {
    require_once __DIR__ . '/environment.php';
}
if (!class_exists('Tester\\Assert')) {
    echo "Install Nette Tester using `composer update --dev`\n";
    exit(1);
}
define("TEMP_DIR", __DIR__ . "/../tmp/");
Tester\Helpers::purge(TEMP_DIR);
Tester\Environment::setup();
$loader = new Nette\Loaders\RobotLoader();
$loader->addDirectory(__DIR__ . '/../src');
$loader->addDirectory(__DIR__ . '/classes');
$loader->addDirectory(__DIR__ . '/Entity');
$loader->setCacheStorage(new Nette\Caching\Storages\FileStorage(__DIR__ . '/../tmp'));
$loader->register();
Exemplo n.º 6
0
<?php

require __DIR__ . '/vendor/autoload.php';
Tracy\Debugger::$strictMode = TRUE;
Tracy\Debugger::enable();
require __DIR__ . '/../src/dibiorm.php';
$loader = new Nette\Loaders\RobotLoader();
$loader->addDirectory(__DIR__ . '/Entities');
$loader->setCacheStorage(new Nette\Caching\Storages\FileStorage('temp'));
$loader->register();
$parameters = array('database' => array('host' => 'localhost', 'username' => 'root', 'password' => '', 'database' => 'dibi-orm', 'driver' => 'mysqli'), 'entityNamespace' => 'doublemcz\\dibiorm\\Examples\\Entities', 'proxiesPath' => __DIR__ . '/temp', 'storage' => new Nette\Caching\Storages\MemoryStorage());
$entityManager = new \doublemcz\dibiorm\Manager($parameters);
/**** ADD NEW USER **/
//$user = new \doublemcz\dibiorm\Examples\Entities\User();
//$user->fullname = 'Test';
//$user->birthDate = new DateTime('1988-08-03 15:00');
//$entityManager->persist($user);
//$entityManager->flush();
/**** FIND USER AND CHANGE HIM ****/
/** @var \doublemcz\dibiorm\Examples\Entities\User $user */
//$city = new \doublemcz\dibiorm\Examples\Entities\City();
//$city->name = 'Pisek';
//$city->population = 30000;
//$entityManager->persist($city);
$user = $entityManager->find('User', 1);
//$user->fullname = 'Test';
//$user->setCity($city);
//$entityManager->flush();
//dump($user);
dump($user->getCity()->name);
die('end');
Exemplo n.º 7
0
<?php

require_once 'vendor/autoload.php';
\Tracy\Debugger::enable();
\Tracy\Debugger::$maxDepth = 32;
$loader = new \Nette\Loaders\RobotLoader();
$loader->addDirectory('Billers');
$loader->setCacheStorage(new \Nette\Caching\Storages\FileStorage('cache'));
$loader->register();
$biller = new \CzechCash\Billers\Billers\OptimalPayments\OptimalPaymentsBiller();
var_dump($biller->isServiceAvailable());
$expiry = new \CzechCash\Billers\Structures\CreditCards\CreditCardExpiry('09/16');
$card = new \CzechCash\Billers\Structures\CreditCards\CreditCard('4107857757053670', $expiry, 123);
$details = ['street' => 'abcd', 'city' => 'efgh', 'state' => 'cjdsfkjds', 'country' => 'AD', 'zip' => 'fjsdkfjsd'];
try {
    \Tracy\Debugger::dump($biller->createCreditCardPayment(10, $card, $details)->process());
} catch (OptimalPayments\NetbanxException $e) {
    \Tracy\Debugger::dump($e);
}
Exemplo n.º 8
0
<?php

namespace ActiveMapperTests;

require_once __DIR__ . "/../libs/Nette/loader.php";
\Nette\Debug::enable(\Nette\Debug::DEVELOPMENT);
\Nette\Environment::setVariable("tempDir", __DIR__ . "/_temp");
$loader = new \Nette\Loaders\RobotLoader();
$loader->addDirectory(__DIR__ . "/../libs");
$loader->addDirectory(__DIR__ . "/../ActiveMapper");
$loader->addDirectory(__DIR__ . "/../examples/Models");
$loader->register();
\dibi::connect(array('driver' => "sqlite3", 'database' => ":memory:", 'formatDateTime' => "'Y-m-d H:i:s'", 'lazy' => TRUE, 'profiler' => TRUE));
\dibi::loadFile(__DIR__ . "/db.structure.sql");
\dibi::loadFile(__DIR__ . "/db.data.sql");
Exemplo n.º 9
0
<?php

require __DIR__ . '/../vendor/autoload.php';
$loader = new \Nette\Loaders\RobotLoader();
$loader->addDirectory(__DIR__ . '/../Billers');
$loader->setCacheStorage(new \Nette\Caching\Storages\FileStorage(__DIR__ . '/../cache'));
$loader->register();
Exemplo n.º 10
0
<?php

use Tester\Environment;
ini_set('html_errors', FALSE);
// we don't want HTML errors in console
$baseDir = __DIR__ . '/../../';
require $baseDir . 'vendor/autoload.php';
Environment::setup();
define('TEMP_DIR', __DIR__ . '/../temp');
@mkdir(TEMP_DIR . '/cache', 0777, TRUE);
// @ - dir may already exist
$loader = new Nette\Loaders\RobotLoader();
$loader->setCacheStorage(new Nette\Caching\Storages\FileStorage(TEMP_DIR))->addDirectory($baseDir . 'app')->addDirectory($baseDir . 'tests')->register();
Exemplo n.º 11
0
<?php

require __DIR__ . '/../vendor/autoload.php';
$loader = new Nette\Loaders\RobotLoader();
$loader->addDirectory(__DIR__ . "/../src");
$loader->setCacheStorage(new \Nette\Caching\Storages\FileStorage('temp'));
$loader->register();
Exemplo n.º 12
0
<?php

if (@(!(include __DIR__ . '/../vendor/autoload.php')) || @(!(include __DIR__ . '/../vendor/nette/tester/Tester/bootstrap.php'))) {
    echo 'Install Nette Tester using `composer update --dev`';
    exit(1);
}
define('TEMP_DIR', __DIR__ . '/../tmp/' . getmypid());
@mkdir(dirname(TEMP_DIR));
// @ - directory may already exist
Tester\Helpers::purge(TEMP_DIR);
function id($val)
{
    return $val;
}
$cacheStorage = new Nette\Caching\Storages\FileStorage(TEMP_DIR);
$loader = new Nette\Loaders\RobotLoader();
$loader->setCacheStorage($cacheStorage);
$loader->addDirectory(__DIR__ . '/../NiceORM');
$loader->addDirectory(__DIR__ . '/stubs');
$loader->addDirectory(__DIR__ . '/model');
$loader->register();
Exemplo n.º 13
0
<?php

namespace App;

require_once __DIR__ . "/../libs/Nette/loader.php";
\Nette\Debug::enable(\Nette\Debug::DEVELOPMENT);
\Nette\Environment::setVariable("tempDir", __DIR__ . "/temp");
$loader = new \Nette\Loaders\RobotLoader();
$loader->addDirectory(__DIR__ . "/../libs");
$loader->addDirectory(__DIR__ . "/../ActiveMapper");
$loader->addDirectory(__DIR__);
$loader->register();
\dibi::connect(array('driver' => "sqlite3", 'database' => ":memory:", 'formatDateTime' => "'Y-m-d H:i:s'", 'lazy' => TRUE, 'profiler' => TRUE));
\dibi::loadFile(__DIR__ . "/db.structure.sql");
\dibi::loadFile(__DIR__ . "/db.data.sql");
function echoBeginHtml()
{
    echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head>' . '<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>ActiveMapper Demo</title></head><body>';
}
Exemplo n.º 14
0
<?php

namespace {
    if (@(!(include __DIR__ . '/../vendor/autoload.php'))) {
        echo 'Install Nette Tester using `composer update --dev`';
        exit(1);
    }
    Tester\Environment::setup();
    date_default_timezone_set('Europe/Prague');
    $_GET = $_POST = $_COOKIE = array();
    define('TEMP_DIR', __DIR__ . '/tmp/' . getmypid());
    @mkdir(dirname(TEMP_DIR));
    Tester\Helpers::purge(TEMP_DIR);
    if (extension_loaded('xdebug')) {
        xdebug_disable();
        Tester\CodeCoverage\Collector::start(__DIR__ . '/coverage.dat');
    }
    function test(\Closure $function)
    {
        $function();
    }
    $loader = new Nette\Loaders\RobotLoader();
    $loader->addDirectory(__DIR__ . '/../src/Acidclick/Rest');
    $loader->setCacheStorage(new Nette\Caching\Storages\FileStorage(__DIR__ . '/tmp'));
    $loader->register();
    // Run the RobotLoader
}
Exemplo n.º 15
0
 protected function execute(InputInterface $input, OutputInterface $output) : int
 {
     $rootDir = realpath(__DIR__ . '/../..');
     $tmpDir = $rootDir . '/tmp';
     $confDir = $rootDir . '/conf';
     $configurator = new Configurator();
     $configurator->defaultExtensions = [];
     $configurator->setDebugMode(true);
     $configurator->setTempDirectory($tmpDir);
     $configurator->enableDebugger($tmpDir . '/log');
     $projectConfigFile = $input->getOption('configuration');
     $levelOption = $input->getOption(self::OPTION_LEVEL);
     if ($projectConfigFile === null && $levelOption === null) {
         $levelOption = self::DEFAULT_LEVEL;
     }
     $configFiles = [$confDir . '/config.neon'];
     if ($levelOption !== null) {
         $levelConfigFile = sprintf('%s/config.level%s.neon', $confDir, $levelOption);
         if (!is_file($levelConfigFile)) {
             $output->writeln(sprintf('Level config file %s was not found.', $levelConfigFile));
             return 1;
         }
         $configFiles[] = $levelConfigFile;
     }
     if ($projectConfigFile !== null) {
         $projectConfigRealFilePath = realpath($projectConfigFile);
         if (!is_file($projectConfigFile)) {
             $output->writeln(sprintf('Project config file at path %s does not exist.', $projectConfigRealFilePath !== false ? $projectConfigRealFilePath : $projectConfigFile));
             return 1;
         }
         $configFiles[] = $projectConfigRealFilePath;
     }
     foreach ($configFiles as $configFile) {
         $configurator->addConfig($configFile);
     }
     $configurator->addParameters(['rootDir' => $rootDir]);
     $container = $configurator->createContainer();
     if (!isset($container->parameters['customRulesetUsed'])) {
         $output->writeln('');
         $output->writeln('<comment>No rules detected</comment>');
         $output->writeln('');
         $output->writeln('You have the following choices:');
         $output->writeln('');
         $output->writeln('* while running the analyse option, use the <info>--level</info> option to adjust your rule level - the higher the stricter');
         $output->writeln('');
         $output->writeln(sprintf('* create your own <info>custom ruleset</info> by selecting which rules you want to check by copying the service definitions from the built-in config level files in <options=bold>%s</>.', realpath(__DIR__ . '/../../conf')));
         $output->writeln('  * in this case, don\'t forget to define parameter <options=bold>customRulesetUsed</> in your config file.');
         $output->writeln('');
         return 1;
     }
     Debugger::$browser = $container->parameters['debug_cli_browser'];
     foreach ($container->parameters['autoload_files'] as $autoloadFile) {
         require_once $autoloadFile;
     }
     if (count($container->parameters['autoload_directories']) > 0) {
         $robotLoader = new \Nette\Loaders\RobotLoader();
         $robotLoader->setCacheStorage(new \Nette\Caching\Storages\MemoryStorage());
         foreach ($container->parameters['autoload_directories'] as $directory) {
             $robotLoader->addDirectory($directory);
         }
         $robotLoader->register();
     }
     $application = $container->getByType(AnalyseApplication::class);
     return $application->analyse($input->getArgument('paths'), new ErrorsConsoleStyle($input, $output));
 }
Exemplo n.º 16
0
/**
 * My Application bootstrap file.
 *
 * @copyright  Copyright (c) 2009 John Doe
 * @package    MyApplication
 */
// Step 1: Load Nette Framework
// this allows load Nette Framework classes automatically so that
// you don't have to litter your code with 'require' statements
require __DIR__ . '/../../vendor/autoload.php';
// Step 2: Configure environment
// 2a) enable Nette\Debug for better exception and error visualisation
\Nette\Diagnostics\Debugger::enable(\Nette\Diagnostics\Debugger::DEVELOPMENT, APP_DIR . "/log");
// 2b) load configuration from config.ini file
//Nette\Environment::loadConfig();
// Step 3: Configure application
// 3a) get and setup a front controller
$application = Nette\Environment::getApplication();
$application->errorPresenter = 'Error';
//$application->catchExceptions = TRUE;
$loader = new \Nette\Loaders\RobotLoader();
$loader->setCacheStorage(Nette\Environment::getContext()->cacheStorage);
$loader->addDirectory(APP_DIR);
$loader->register();
use Nette\Application\Routers\Route;
// Step 4: Setup application router
$router = $application->getRouter();
$router[] = new Route('index.php', array('presenter' => 'Download', 'action' => 'default'), Route::ONE_WAY);
$router[] = new Route('<presenter>/<action>/<id>', array('presenter' => 'Download', 'action' => 'default', 'id' => NULL));
// Step 5: Run the application!
$application->run();
Exemplo n.º 17
0
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"
      integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">

<?php 
define('SRC_DIR', __DIR__ . '/../src/');
require_once __DIR__ . '/../vendor/autoload.php';
@mkdir(__DIR__ . '/log');
@mkdir(__DIR__ . '/tmp');
\Tracy\Debugger::enable(\Tracy\Debugger::DEVELOPMENT, __DIR__ . '/log');
$loader = new Nette\Loaders\RobotLoader();
$loader->addDirectory(SRC_DIR);
$loader->setCacheStorage(new Nette\Caching\Storages\FileStorage(__DIR__ . '/tmp'));
$loader->register();
?>

<hr>

<div class="container">
	<h2>Basic functionality</h2>

	<hr>

	<?php 
$table = new \Mesour\UI\Table();
$data = [['id' => 1, 'group_id' => 1, 'method' => 'setName', 'returns' => 'Mesour\\Table\\Column', 'description' => 'Set column name.'], ['id' => 2, 'group_id' => 2, 'method' => 'setHeader', 'returns' => 'Mesour\\Table\\Column', 'description' => 'Set header text.'], ['id' => 3, 'group_id' => 1, 'method' => 'setCallback', 'returns' => 'Mesour\\Table\\Column', 'description' => 'Set render callback.']];
$source = new \Mesour\Sources\ArraySource('methods', 'id', $data, ['groups' => [['id' => 1, 'name' => 'Test 1'], ['id' => 2, 'name' => 'Test 2']], 'parameters' => [['id' => 1, 'method_id' => 1, 'name' => '$name'], ['id' => 2, 'method_id' => 1, 'name' => '$identifier'], ['id' => 3, 'method_id' => 3, 'name' => 'array $data']], 'types' => [['id' => 1, 'name' => 'first', 'verified' => 0], ['id' => 2, 'name' => 'second', 'verified' => 1], ['id' => 3, 'name' => 'third', 'verified' => 0]], 'method_types' => [['method_id' => 1, 'type_id' => 1], ['method_id' => 1, 'type_id' => 2], ['method_id' => 1, 'type_id' => 3], ['method_id' => 2, 'type_id' => 2]]]);
$table->setSource($source);
$dataStructure = $source->getDataStructure();
$groupsStructure = $dataStructure->getOrCreateTableStructure('groups', 'id');
$groupsStructure->addNumber('id');
Exemplo n.º 18
0
<?php

if (@(!(include __DIR__ . '/../vendor/autoload.php'))) {
    echo 'Install Nette Tester using `composer update --dev`';
    exit(1);
}
// configure environment
Tester\Environment::setup();
date_default_timezone_set('Europe/Bratislava');
// create temporary directory
define('TEMP_DIR', __DIR__ . '/tmp/' . (isset($_SERVER['argv']) ? md5(serialize($_SERVER['argv'])) : getmypid()));
define('WWW_DIR', TEMP_DIR . '/www_dir');
define('FIXTURES_DIR', __DIR__ . '/fixtures');
Tester\Helpers::purge(TEMP_DIR);
Tester\Helpers::purge(WWW_DIR);
// robot loader
$loader = new Nette\Loaders\RobotLoader();
mkdir(TEMP_DIR . '/cache');
$loader->setCacheStorage(new Nette\Caching\Storages\FileStorage(TEMP_DIR . '/cache'))->addDirectory(__DIR__ . '/../app')->addDirectory(__DIR__ . '/../vendor/others')->addDirectory(__DIR__ . '/fixtures')->register();
$_SERVER = array_intersect_key($_SERVER, array_flip(array('PHP_SELF', 'SCRIPT_NAME', 'SERVER_ADDR', 'SERVER_SOFTWARE', 'HTTP_HOST', 'DOCUMENT_ROOT', 'OS', 'argc', 'argv')));
$_SERVER['REQUEST_TIME'] = 1234567890;
$_ENV = $_GET = $_POST = array();
function id($val)
{
    return $val;
}
function run(Tester\TestCase $testCase)
{
    $testCase->run(isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : NULL);
}
Exemplo n.º 19
0
<?php

define('SRC_DIR', __DIR__ . '/../src/');
define('DISABLE_AUTOLOAD', true);
require_once __DIR__ . '/../vendor/autoload.php';
@mkdir(__DIR__ . "/log");
@mkdir(__DIR__ . "/../tmp");
if (file_exists(__DIR__ . '/environment.php')) {
    require_once __DIR__ . '/environment.php';
}
if (!class_exists('Tester\\Assert')) {
    echo "Install Nette Tester using `composer update --dev`\n";
    exit(1);
}
define("TEMP_DIR", __DIR__ . '/../tmp');
Tester\Helpers::purge(TEMP_DIR);
Tester\Environment::setup();
$loader = new Nette\Loaders\RobotLoader();
$loader->addDirectory(__DIR__ . '/../src');
$loader->addDirectory(__DIR__ . '/../vendor/mesour/sources/tests/classes');
$loader->addDirectory(__DIR__ . '/../vendor/mesour/sources/tests/Entity');
$loader->setCacheStorage(new Nette\Caching\Storages\FileStorage(__DIR__ . '/../tmp'));
$loader->register();
Exemplo n.º 20
0
 /**
  * @param \Venne\Module\IModule $module
  * @return array
  * @throws \Exception
  */
 protected function getAllClasses()
 {
     // find files
     $robotLoader = new \Nette\Loaders\RobotLoader();
     $robotLoader->setCacheStorage(new \Nette\Caching\Storages\MemoryStorage());
     foreach ($this->context->parameters['modules'] as $name => $item) {
         if ($item[ModuleManager::MODULE_STATUS] === ModuleManager::STATUS_INSTALLED) {
             $path = $this->context->expand($item[ModuleManager::MODULE_PATH]) . '/' . ucfirst($name) . 'Module';
             if (file_exists($path)) {
                 $robotLoader->addDirectory($path);
             }
         }
     }
     $robotLoader->register();
     $entities = $robotLoader->getIndexedClasses();
     // classes
     $classes = array();
     foreach ($entities as $class => $item) {
         if (\Nette\Reflection\ClassType::from('\\' . $class)->hasAnnotation('ORM\\Entity')) {
             $classes[] = $class;
         }
     }
     $robotLoader->unregister();
     return $classes;
 }
Exemplo n.º 21
0
<?php

define('SRC_DIR', __DIR__ . '/../src/');
define('DISABLE_AUTOLOAD', true);
require_once __DIR__ . '/../vendor/autoload.php';
@mkdir(__DIR__ . "/log");
@mkdir(__DIR__ . "/tmp");
if (file_exists(__DIR__ . '/environment.php')) {
    require_once __DIR__ . '/environment.php';
}
if (!class_exists('Tester\\Assert')) {
    echo "Install Nette Tester using `composer update --dev`\n";
    exit(1);
}
define("TEMP_DIR", __DIR__ . '/tmp');
Tester\Helpers::purge(TEMP_DIR);
Tester\Environment::setup();
$loader = new Nette\Loaders\RobotLoader();
$loader->addDirectory(__DIR__ . '/../src');
$loader->setCacheStorage(new Nette\Caching\Storages\FileStorage(TEMP_DIR));
$loader->register();
Exemplo n.º 22
0
 protected function execute(InputInterface $input, OutputInterface $output) : int
 {
     $rootDir = realpath(__DIR__ . '/../..');
     $tmpDir = $rootDir . '/tmp';
     $confDir = $rootDir . '/conf';
     $configurator = new Configurator();
     $configurator->defaultExtensions = [];
     $configurator->setDebugMode(true);
     $configurator->setTempDirectory($tmpDir);
     $projectConfigFile = $input->getOption('configuration');
     $levelOption = $input->getOption(self::OPTION_LEVEL);
     $defaultLevelUsed = false;
     if ($projectConfigFile === null && $levelOption === null) {
         $levelOption = self::DEFAULT_LEVEL;
         $defaultLevelUsed = true;
     }
     $configFiles = [$confDir . '/config.neon'];
     if ($levelOption !== null) {
         $levelConfigFile = sprintf('%s/config.level%s.neon', $confDir, $levelOption);
         if (!is_file($levelConfigFile)) {
             $output->writeln(sprintf('Level config file %s was not found.', $levelConfigFile));
             return 1;
         }
         $configFiles[] = $levelConfigFile;
     }
     if ($projectConfigFile !== null) {
         $projectConfigRealFilePath = realpath($projectConfigFile);
         if (!is_file($projectConfigFile)) {
             $output->writeln(sprintf('Project config file at path %s does not exist.', $projectConfigRealFilePath !== false ? $projectConfigRealFilePath : $projectConfigFile));
             return 1;
         }
         $configFiles[] = $projectConfigRealFilePath;
     }
     foreach ($configFiles as $configFile) {
         $configurator->addConfig($configFile);
     }
     $configurator->addParameters(['rootDir' => $rootDir, 'tmpDir' => $tmpDir]);
     $container = $configurator->createContainer();
     $consoleStyle = new ErrorsConsoleStyle($input, $output);
     $memoryLimitFile = $container->parameters['memoryLimitFile'];
     if (file_exists($memoryLimitFile)) {
         $consoleStyle->note(sprintf("PHPStan crashed in the previous run probably because of excessive memory consumption.\nIt consumed around %s of memory.\n\nTo avoid this issue, increase the memory_limit directive in your php.ini file here:\n%s\n\nIf you can't or don't want to change the system-wide memory limit, run PHPStan like this:\n%s", file_get_contents($memoryLimitFile), php_ini_loaded_file(), sprintf('php -d memory_limit=XX %s', implode(' ', $_SERVER['argv']))));
         unlink($memoryLimitFile);
     }
     if (PHP_VERSION_ID >= 70100 && !property_exists(Catch_::class, 'types')) {
         $consoleStyle->note('You\'re running PHP >= 7.1, but you still have PHP-Parser version 2.x. This will lead to parse errors in case you use PHP 7.1 syntax like nullable parameters, iterable and void typehints, union exception types, or class constant visibility. Update to PHP-Parser 3.x to dismiss this message.');
     }
     $this->setUpSignalHandler($consoleStyle, $memoryLimitFile);
     if (!isset($container->parameters['customRulesetUsed'])) {
         $output->writeln('');
         $output->writeln('<comment>No rules detected</comment>');
         $output->writeln('');
         $output->writeln('You have the following choices:');
         $output->writeln('');
         $output->writeln('* while running the analyse option, use the <info>--level</info> option to adjust your rule level - the higher the stricter');
         $output->writeln('');
         $output->writeln(sprintf('* create your own <info>custom ruleset</info> by selecting which rules you want to check by copying the service definitions from the built-in config level files in <options=bold>%s</>.', realpath(__DIR__ . '/../../conf')));
         $output->writeln('  * in this case, don\'t forget to define parameter <options=bold>customRulesetUsed</> in your config file.');
         $output->writeln('');
         return $this->handleReturn(1, $memoryLimitFile);
     } elseif ($container->parameters['customRulesetUsed']) {
         $defaultLevelUsed = false;
     }
     foreach ($container->parameters['autoload_files'] as $autoloadFile) {
         require_once $autoloadFile;
     }
     if (count($container->parameters['autoload_directories']) > 0) {
         $robotLoader = new \Nette\Loaders\RobotLoader();
         $robotLoader->setCacheStorage(new \Nette\Caching\Storages\MemoryStorage());
         foreach ($container->parameters['autoload_directories'] as $directory) {
             $robotLoader->addDirectory($directory);
         }
         $robotLoader->register();
     }
     $application = $container->getByType(AnalyseApplication::class);
     return $this->handleReturn($application->analyse($input->getArgument('paths'), $consoleStyle, $defaultLevelUsed), $memoryLimitFile);
 }
Exemplo n.º 23
0
 /**
  * Load Nette, Doctrine2, project classes and return Nette container
  * @return \SystemContainer Nette 2.2.X container
  */
 private function getNetteContainer()
 {
     $netteContainer = (require static::$netteDirectory . '/bootstrap.php');
     $loader = new \Nette\Loaders\RobotLoader();
     $loader->setCacheStorage(new \Nette\Caching\Storages\DevNullStorage());
     $loader->addDirectory(__DIR__);
     $loader->addDirectory(__DIR__ . '/../../../doctrine/annotations/lib');
     $loader->addDirectory(__DIR__ . '/../../../doctrine/cache/lib');
     $loader->addDirectory(__DIR__ . '/../../../doctrine/common/lib');
     $loader->addDirectory(__DIR__ . '/../../../doctrine/dbal/lib');
     $loader->addDirectory(__DIR__ . '/../../../doctrine/inflector/lib');
     $loader->addDirectory(__DIR__ . '/../../../doctrine/lexer/lib');
     $loader->addDirectory(__DIR__ . '/../../../doctrine/orm/lib');
     $loader->register();
     return $netteContainer;
 }
Exemplo n.º 24
0
#!/usr/bin/env php
<?php 
require __DIR__ . '/vendor/autoload.php';
// Nette loader
$loader = new Nette\Loaders\RobotLoader();
// Add directories for RobotLoader to index
$loader->addDirectory('app');
// And set caching to the 'temp' directory on the disc
$loader->setCacheStorage(new Nette\Caching\Storages\FileStorage('temp'));
$loader->register();
// Run the RobotLoader
// Symfony console
$application = new Symfony\Component\Console\Application('PrestaMigration', '0.1');
$application->add(new App\Console\Command\ExportCommand());
$application->run();