Creates a pre-configured instance of Wise.

@param array|string $paths The configuration directory path(s).
@param string       $cache The cache directory path.
@param boolean      $debug Enable debugging?

@return Wise The instance.
355214
public static function create($paths, $cache = null, $debug = false)
    {
        $wise = new self($debug);

        if ($cache) {
            $wise->setCacheDir($cache);
        }

        $locator = new FileLocator($paths);
        $resolver = new LoaderResolver(
            array(
                new Loader\IniFileLoader($locator),
                new Loader\JsonFileLoader($locator),
                new Loader\PhpFileLoader($locator),
                new Loader\XmlFileLoader($locator),
                new Loader\YamlFileLoader($locator),
            )
        );

        $wise->setCollector(new Resource\ResourceCollector());
        $wise->setLoader(new DelegatingLoader($resolver));

        $resolver->setResourceCollector($wise->getCollector());
        $resolver->setWise($wise);

        return $wise;
    }
436776
private function static_file_default(
		string $path, int $cache=0, string $disposition=null
	) {
		if (file_exists($path))
			static::send_file($path, $disposition, 200, $cache);
		$this->abort(404);
	}
812122
public function setDebugging(string $debugging = "F") : CNabuDataObject
    {
        if ($debugging === null) {
            throw new ENabuCoreException(
                    ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
                    array("\$debugging")
            );
        }
        $this->setValue('nb_site_module_debugging', $debugging);
        
        return $this;
    }
1048281
public static function createConfiguration($isDevMode = false, $proxyDir = null, Cache $cache = null)
    {
        $proxyDir = $proxyDir ?: sys_get_temp_dir();

        if ($isDevMode === false && $cache === null) {
            if (extension_loaded('apc')) {
                $cache = new \Doctrine\Common\Cache\ApcCache();
            } elseif (extension_loaded('xcache')) {
                $cache = new \Doctrine\Common\Cache\XcacheCache();
            } elseif (extension_loaded('memcache')) {
                $memcache = new \Memcache();
                $memcache->connect('127.0.0.1');
                $cache = new \Doctrine\Common\Cache\MemcacheCache();
                $cache->setMemcache($memcache);
            } elseif (extension_loaded('redis')) {
                $redis = new \Redis();
                $redis->connect('127.0.0.1');
                $cache = new \Doctrine\Common\Cache\RedisCache();
                $cache->setRedis($redis);
            } else {
                $cache = new ArrayCache();
            }
        } elseif ($cache === null) {
            $cache = new ArrayCache();
        }

        if ($cache instanceof CacheProvider) {
            $cache->setNamespace("dc2_" . md5($proxyDir) . "_"); // to avoid collisions
        }

        $config = new Configuration();
        $config->setMetadataCacheImpl($cache);
        $config->setQueryCacheImpl($cache);
        $config->setResultCacheImpl($cache);
        $config->setProxyDir($proxyDir);
        $config->setProxyNamespace('DoctrineProxies');
        $config->setAutoGenerateProxyClasses($isDevMode);

        return $config;
    }
640712
public function getStatementsForFile($file_path, $debug_output = false)
    {
        $from_cache = false;

        $version = (string) PHP_PARSER_VERSION . $this->this_modified_time;

        $file_contents = $this->file_provider->getContents($file_path);
        $modified_time = $this->file_provider->getModifiedTime($file_path);

        if (!$this->parser_cache_provider) {
            if ($debug_output) {
                echo 'Parsing ' . $file_path . "\n";
            }

            $stmts = self::parseStatements($file_contents, $file_path);

            return $stmts ?: [];
        }

        $file_content_hash = md5($version . $file_contents);

        $stmts = $this->parser_cache_provider->loadStatementsFromCache(
            $file_path,
            $modified_time,
            $file_content_hash
        );

        if ($stmts === null) {
            if ($debug_output) {
                echo 'Parsing ' . $file_path . "\n";
            }

            $existing_statements = $this->parser_cache_provider->loadExistingStatementsFromCache($file_path);

            if ($existing_statements && !$existing_statements[0] instanceof PhpParser\Node\Stmt) {
                $existing_statements = null;
            }

            $existing_file_contents = $this->parser_cache_provider->loadExistingFileContentsFromCache($file_path);

            // this happens after editing temporary file
            if ($existing_file_contents === $file_contents && $existing_statements) {
                $this->diff_map[$file_path] = [];
                $this->parser_cache_provider->saveStatementsToCache(
                    $file_path,
                    $file_content_hash,
                    $existing_statements,
                    true
                );

                return $existing_statements;
            }

            $file_changes = null;

            $existing_statements_copy = null;

            if ($existing_statements
                && $existing_file_contents
                && abs(strlen($existing_file_contents) - strlen($file_contents)) < 5000
            ) {
                $file_changes = \Psalm\Internal\Diff\FileDiffer::getDiff($existing_file_contents, $file_contents);

                if (count($file_changes) < 10) {
                    $traverser = new PhpParser\NodeTraverser;
                    $traverser->addVisitor(new \Psalm\Internal\Visitor\CloningVisitor);
                    // performs a deep clone
                    /** @var array<int, PhpParser\Node\Stmt> */
                    $existing_statements_copy = $traverser->traverse($existing_statements);
                } else {
                    $file_changes = null;
                }
            }

            $stmts = self::parseStatements(
                $file_contents,
                $file_path,
                $existing_file_contents,
                $existing_statements_copy,
                $file_changes
            );

            if ($existing_file_contents && $existing_statements) {
                list($unchanged_members, $unchanged_signature_members, $changed_members, $diff_map)
                    = \Psalm\Internal\Diff\FileStatementsDiffer::diff(
                        $existing_statements,
                        $stmts,
                        $existing_file_contents,
                        $file_contents
                    );

                $unchanged_members = array_map(
                    /**
                     * @param int $_
                     * @return bool
                     */
                    function ($_) {
                        return true;
                    },
                    array_flip($unchanged_members)
                );

                $unchanged_signature_members = array_map(
                    /**
                     * @param int $_
                     * @return bool
                     */
                    function ($_) {
                        return true;
                    },
                    array_flip($unchanged_signature_members)
                );

                $file_path_hash = \md5($file_path);

                $changed_members = array_map(
                    function (string $key) use ($file_path_hash) : string {
                        if (substr($key, 0, 4) === 'use:') {
                            return $key . ':' . $file_path_hash;
                        }

                        return $key;
                    },
                    $changed_members
                );

                $changed_members = array_map(
                    /**
                     * @param int $_
                     * @return bool
                     */
                    function ($_) {
                        return true;
                    },
                    array_flip($changed_members)
                );

                if (isset($this->unchanged_members[$file_path])) {
                    $this->unchanged_members[$file_path] = array_intersect_key(
                        $this->unchanged_members[$file_path],
                        $unchanged_members
                    );
                } else {
                    $this->unchanged_members[$file_path] = $unchanged_members;
                }

                if (isset($this->unchanged_signature_members[$file_path])) {
                    $this->unchanged_signature_members[$file_path] = array_intersect_key(
                        $this->unchanged_signature_members[$file_path],
                        $unchanged_signature_members
                    );
                } else {
                    $this->unchanged_signature_members[$file_path] = $unchanged_signature_members;
                }

                if (isset($this->changed_members[$file_path])) {
                    $this->changed_members[$file_path] = array_merge(
                        $this->changed_members[$file_path],
                        $changed_members
                    );
                } else {
                    $this->changed_members[$file_path] = $changed_members;
                }

                $this->diff_map[$file_path] = $diff_map;
            }

            if ($this->file_storage_cache_provider) {
                $this->file_storage_cache_provider->removeCacheForFile($file_path);
            }

            $this->parser_cache_provider->cacheFileContents($file_path, $file_contents);
        } else {
            $from_cache = true;
            $this->diff_map[$file_path] = [];
        }

        $this->parser_cache_provider->saveStatementsToCache($file_path, $file_content_hash, $stmts, $from_cache);

        if (!$stmts) {
            return [];
        }

        return $stmts;
    }
960591
public function setCurlDebugging($debug = true) {
        $this->blocktrailClient->setCurlDebugging($debug);
        $this->dataClient->setCurlDebugging($debug);
    }
1234057
public static function factory($config = array())
    {
        Version::warn(__METHOD__ . ' is deprecated');
        if (!is_array($config)) {
            throw new InvalidArgumentException('$config must be an array');
        }

        if (!isset($config['cache.adapter']) && !isset($config['cache.provider'])) {
            $config['cache.adapter'] = 'Guzzle\Cache\NullCacheAdapter';
            $config['cache.provider'] = null;
        } else {
            // Validate that the options are valid
            foreach (array('cache.adapter', 'cache.provider') as $required) {
                if (!isset($config[$required])) {
                    throw new InvalidArgumentException("{$required} is a required CacheAdapterFactory option");
                }
                if (is_string($config[$required])) {
                    // Convert dot notation to namespaces
                    $config[$required] = str_replace('.', '\\', $config[$required]);
                    if (!class_exists($config[$required])) {
                        throw new InvalidArgumentException("{$config[$required]} is not a valid class for {$required}");
                    }
                }
            }
            // Instantiate the cache provider
            if (is_string($config['cache.provider'])) {
                $args = isset($config['cache.provider.args']) ? $config['cache.provider.args'] : null;
                $config['cache.provider'] = self::createObject($config['cache.provider'], $args);
            }
        }

        // Instantiate the cache adapter using the provider and options
        if (is_string($config['cache.adapter'])) {
            $args = isset($config['cache.adapter.args']) ? $config['cache.adapter.args'] : array();
            array_unshift($args, $config['cache.provider']);
            $config['cache.adapter'] = self::createObject($config['cache.adapter'], $args);
        }

        return $config['cache.adapter'];
    }
1357714
private static function createContainerConfigList(array $conf, bool $debug, float $startedAt){
        return array_merge(
            [new ContainerConfig\AppConfig($debug)],
            $conf,
            [
                new ContainerConfig\TraitConfig(),
                new ContainerConfig\TypeConfig(),
                new ContainerConfig\ActionConfig(),
                new ContainerConfig\MiddlewareConfig()
            ],
            $debug ? [new ContainerConfig\DebugConfig($startedAt)] : [],
            [new ContainerConfig\CoreConfig()]
        );
    }
1035702
public static function createYAMLMetadataConfiguration(array $paths, $isDevMode = false, $proxyDir = null, Cache $cache = null)
    {
        $config = self::createConfiguration($isDevMode, $proxyDir, $cache);
        $config->setMetadataDriverImpl(new YamlDriver($paths));

        return $config;
    }
494658
public function setCache($cache, $path, $reload = true)
    {
        $this->_cache        = (bool) $cache;
        $this->_cache_path   = $path;
        $this->_caceh_reload = $reload;

        return $this;
    }
1231892
public function getQueue(Debugger $debugger)
    {
        /** @var \Indatus\Dispatcher\Queue $queue */
        $queue = App::make('Indatus\Dispatcher\Queue');

        /** @var \Indatus\Dispatcher\Scheduling\ScheduledCommandInterface $command */
        foreach ($this->getScheduledCommands() as $command) {
            /** @var \Indatus\Dispatcher\Scheduling\Schedulable $scheduler */
            $scheduler = App::make('Indatus\Dispatcher\Scheduling\Schedulable');

            //could be multiple schedules based on arguments
            $schedules = $command->schedule($scheduler);
            if (!is_array($schedules)) {
                $schedules = [$schedules];
            }

            $willBeRun = false;
            foreach ($schedules as $schedule) {
                if (($schedule instanceof Schedulable) === false) {
                    $msg = 'Schedule for "'.$command->getName().'" is not an instance of Schedulable';
                    throw new \InvalidArgumentException($msg);
                }

                if ($this->isDue($schedule)) {
                    /** @var \Indatus\Dispatcher\QueueItem $queueItem */
                    $queueItem = App::make('Indatus\Dispatcher\QueueItem');

                    $queueItem->setCommand($command);
                    $queueItem->setScheduler($schedule);

                    if ($queue->add($queueItem)) {
                        $willBeRun = true;
                    }
                }
            }

            //it didn't run, so record that it didn't run
            if ($willBeRun === false) {
                $debugger->commandNotRun($command, 'No schedules were due');
            }
        }

        return $queue;
    }
435688
public static DirectoryStream.Filter<Path> notInCaches(Set<String> caches) {
        checkNotNull(caches, "set of active caches can't be null");
        return new NotInCachesFilter(caches);
    }
388470
public function cachedCompiler($outputDir = '', $debug = false)
    {
        $outputDir = $outputDir ?: CACHE . 'asset_compress' . DS;
        $debug = $debug ?: Configure::read('debug');

        return parent::cachedCompiler($outputDir, $debug);
    }
809150
static function setCachedTree( $originalKey, $uri, $res, $templatePath, &$extraParameters, &$root )
    {
        if ( $root === null )
            return;
        $templateCache =& eZTemplateTreeCache::cacheTable();
        $key = eZTemplateTreeCache::internalKey( $originalKey );
        if ( isset( $templateCache[$key] ) )
        {
            eZDebug::writeDebug( "Template cache for key '$key', created from uri '$uri', already exists", __METHOD__ );
        }
        else
        {
            $templateCache[$key] = array();
        }
        $ini = eZINI::instance();
        $debug = $ini->variable( 'TemplateSettings', 'Debug' ) == 'enabled';
        $templateCache[$key]['root'] =& $root;
        $templateCache[$key]['info'] = array( 'original_key' => $originalKey,
                                              'key' => $key,
                                              'uri' => $uri,
                                              'debug' => $debug,
                                              'resource' => $res,
                                              'template_path' => $templatePath,
                                              'resource_parameters' => $extraParameters );
    }
1260983
public static function copyResources($dest, $force, $filename_path, $debug)
    {
        if (file_exists($filename_path)) {
            $destfolder = basename($filename_path);
            if (!file_exists(WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder) || $debug || $force) {
                if (is_dir($filename_path)) {
                    self::copyr($filename_path, WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder);
                } else {
                    if (@copy($filename_path, WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder) === FALSE) {
                        throw new ConfigException("Can't copy " . $filename_path . " to " . WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder);
                    }
                }
            }
        }
    }
992704
private function generateConfigFile($db, $siteName, $key, $debug)
    {
        $user = $db['username'];
        $pass = $db['password'];
        $dsn  = $db['dsn'];

        $config = "<?php return array(
	        'name' => '{$siteName}',
	        'components' => array(
	            'db' => array(
	                'class' => 'CDbConnection',
	                'connectionString' => '{$dsn}',
	                'emulatePrepare' => true,
	                'username' => '{$user}',
	                'password' => '{$pass}',
	                'charset' => 'utf8',
	                'schemaCachingDuration' => '3600'
	            ),
	            'cache' => array(
	                'class' => 'CFileCache',
	            ),
	        ),
	        'params' => require('params.php')
	    );";
        
        $trace = $debug ? 3 : 0;
        $params = "<?php return array(
        	'encryptionKey' => '{$key}'
        );";

        // Write the configuration file out
        $this->writeFile(Yii::getPathOfAlias('application.config').DS.'main.php', $config);
        $this->writeFile(Yii::getPathOfAlias('application.config').DS.'params.php', $params);
    }
46402
public function initCache(Cache $cache, $enableCache = false)
    {
        $this->cache          = $cache;
        $this->isCacheEnabled = $enableCache;

        if ($enableCache) {
            $this->cache->enable();
        } else {
            $this->cache->disable();
        }

        return $this;
    }