Load all kind of symbols from php files previously created
by \Peg\Lib\Definitions\Exporter.
@param string $path Directory where the php files reside.
164803
private function LoadFromPHP($path)
    {
        $this->definitions_path = rtrim($path, "/\\") . "/";
        $this->import_type = Type::PHP;
        
        // This variable is used by the php definition files to reference
        // this object and populate it with elements.
        $symbols =& $this->symbols;
        
        if(file_exists($this->definitions_path . "constants.php"))
        {
            $this->SendMessage(t("Loading constants.php"));
            include($this->definitions_path . "constants.php");
        }
        
        if(file_exists($this->definitions_path . "enumerations.php"))
        {
            $this->SendMessage(t("Loading enumerations.php"));
            include($this->definitions_path . "enumerations.php");
        }
        
        if(file_exists($this->definitions_path . "type_definitions.php"))
        {
            $this->SendMessage(t("Loading type_definitions.php"));
            include($this->definitions_path . "type_definitions.php");
        }
        
        if(file_exists($this->definitions_path . "variables.php"))
        {
            $this->SendMessage(t("Loading variables.php"));
            include($this->definitions_path . "variables.php");
        }
        
        if(file_exists($this->definitions_path . "functions.php"))
        {
            $this->SendMessage(t("Loading functions.php"));
            include($this->definitions_path . "functions.php");
        }
        
        if(file_exists($this->definitions_path . "classes.php"))
        {
            $this->SendMessage(t("Loading classes.php"));
            include($this->definitions_path . "classes.php");
        }
    }
461918
protected function loadPath($path) {
        if (directory_exists($path)) {
            return $this->loadDirectory($path);
        } else if (file_exists($path)) {
            return $this->loadFile($path);
        }

        return [];
    }
426391
protected function load(string $path): void
    {
        $namespace = $this->app->getNamespace();

        /** @var SplFileInfo[] $files */
        $files = (new Finder)->in($path)->files();

        foreach ($files as $file) {
            $file = $namespace.str_replace(
                    ['/', '.php'],
                    ['\\', ''],
                    Str::after($file->getPathname(), app_path().DIRECTORY_SEPARATOR)
                );

            if (is_subclass_of($file, Intent::class) && !(new ReflectionClass($file))->isAbstract()) {
                $this->app['conversation']->registerIntent($file);
            }
        }
    }
657369
public function loadFromDirectory($path)
    {
        return $this->file->listFiles($path)->mapWithKeys(function ($file, $key) {
            return [$key => $this->loadFile($file)];
        });
    }
1194241
public static function initialize(?string $path = null): void
    {
        if (self::$isLoaded === true) {
            return;
        }

        // Load dotenv.
        self::$path = $path;
        if (self::$path === null) {
            self::$path = Path::root();
        }
        if (File::exist(self::$path . '/.env')) {
            self::$dotenv = new Dotenv(self::$path);
            self::$dotenv->load();
        }

        // Initialize repositories.
        if (!is_array(self::$repositories)) {
            self::$repositories = [];
        }

        self::$isLoaded = true;
    }
356959
public static function register($path)
	{
		self::$_path = $path;
		self::addPath($path);

		if ($loaders = spl_autoload_functions())
			array_map('spl_autoload_unregister', $loaders);
		else
			$loaders = function_exists('__autoload') ? array('__autoload') : array();

		array_unshift($loaders, array(__CLASS__, 'load'));
		array_map('spl_autoload_register', $loaders);
	}
1145820
public static function load($path = BASE_DIR) {
        $librariesDir = dirname(dirname($path)) . DS . 'libraries';
        foreach (glob($librariesDir . DS . "*.php") as $filename) {
            require_once $filename;
        }
    }
1104409
public static function loadDotFile($path)
    {
        $file = file_get_contents($path);
        if ($file === false) {
            return null;
        }

        $file = str_replace("\r", "\n", $file);      // Turn CR into LF
        $file = str_replace("\n\n", "\n", $file);   // Turn LFLF into LF
        $lines = explode("\n", $file);

        $data = [];

        $lineCount = count($lines);

        for ($i = 0; $i < $lineCount; $i++) {
            $line = trim($lines[$i]);
            if (strlen($line) === 0) {
                continue;
            }

            $split = explode('=', $line, 2);
            if (count($split) < 2) {
                throw new Exception\ConfigurationException("Invalid data in .bitrank file on line $i. ($line)");
            }

            $key = $split[0];
            $value = $split[1];

            $data[$key] = $value;
        }

        return $data;
    }
1172377
public function loadFrom(string $path): void
    {
        $this->path = $path;

        if (is_file($path)) {
            $this->data = require $path;

            if (!is_array($this->data)) {
                throw new ConfigException("Config loaded from path={$path} is not an array");
            }

            $this->loadedAt = time();
        } else {
            throw new ConfigException('Unable to load config from path=' . $path);
        }
    }
433584
public function autoloadPath($path)
    {
        $files = glob($path);
        if ($files && count($files)) {
            foreach ($files as $file) {
                if (file_exists($file) && is_dir($file)) {
                    $this->autoloadPath($file . "/*");
                }
                if (file_exists($file) && is_file($file)) {
                    require_once($file);
                }
            }
        }
    }
855500
public function compile($path = null)
    {
        if ($path) {
            $this->setPath($path);
        }

        if (! is_null($this->cachePath)) {
            $contents = $this->compileString(
                $this->files->get($this->getPath())
            );

            if (! empty($this->getPath())) {
                $tokens = $this->getOpenAndClosingPhpTokens($contents);

                // If the tokens we retrieved from the compiled contents have at least
                // one opening tag and if that last token isn't the closing tag, we
                // need to close the statement before adding the path at the end.
                if ($tokens->isNotEmpty() && $tokens->last() !== T_CLOSE_TAG) {
                    $contents .= ' ?>';
                }

                $contents .= "<?php /**PATH {$this->getPath()} ENDPATH**/ ?>";
            }

            $this->files->put(
                $this->getCompiledPath($this->getPath()), $contents
            );
        }
    }
1101317
public static function mkfolders($path){
        $exFolder = explode("/", $path);
        $curpath = "";
        if(is_array($exFolder)) foreach ($exFolder as $key => $value) {
            if($value && $value != "." && $value != ".."){
                $curpath = $curpath."/".$value;
                File::mkfolder($curpath);
            }else if($value == "." || $value == ".."){
                $curpath = $value;
            }
        }
    }
1073528
protected function loadFilePath($path) {
		$realPath = realpath($path);
		if (DIRECTORY_SEPARATOR == '\\') { // windows
			$realPath = str_replace('\\', '\\\\', $realPath);
		}
		return $this->db->real_escape_string($realPath);
	}
105224
private static function load($path)
    {
        // Load language file
        if (file_exists($path)) {
            require($path);
        }

        // Populate dictionary ($dictionary is declared inside $path)
        if (isset($dictionary) && is_array($dictionary)) {
            self::$_dictionary = array_merge(self::$_dictionary, $dictionary);
        }

        // Populate transliterations ($transliterations is declared inside $path)
        if (isset($transliterations) && is_array($transliterations)) {
            self::$_transliterations = array_merge(self::$_transliterations, $transliterations);
        }
    }
616304
private static function loadDefinitionsFromPath(string $path): array
    {
        if (!\file_exists($path)) {
            throw new \RuntimeException(\sprintf('Path "%s" does not exist', $path));
        }

        if (!\is_dir($path)) {
            return self::loadDefinitionsFromFile($path);
        }

        $definitions = [];
        foreach (\glob($path . '/*.php', \GLOB_ERR) as $file) {
            if (\is_file($file)) {
                $definitions[] = self::loadDefinitionsFromFile($file);
            }
        }

        return \count($definitions) === 0 ? [] : \array_merge(...$definitions);
    }
1372266
protected function createFileDir($path)
    {
        if (!file_exists($path)) {
            $this->createFileDir(dirname($path));
            mkdir($path, 0777);
        }
    }
131940
public static function loadPatternsInPath($path)
    {
        $patterns = array();

        if ($handle = opendir($path)) {
            while (false !== ($entry = readdir($handle))) {
                $fullPath = $path . '/' . $entry;

                if ($entry != '..' && $entry != '.' && is_dir($fullPath)) {
                    $id = trim(str_replace(Primer::$PATTERN_PATH, '', $fullPath), '/');

                    // Load the pattern
                    $patterns[] = new Pattern($id);
                }
            }

            closedir($handle);
        }

        return $patterns;
    }