Scalr\Tests\System\Config\ExtensionTest::getConfigUsedVars PHP Method

getConfigUsedVars() protected method

Scans all code searching usage of the config parameters
protected getConfigUsedVars ( ) : array
return array Returns array with dot notation access name keys
    protected function getConfigUsedVars()
    {
        $root = realpath(APPPATH . '/..');
        $vars = array();
        $i = 0;
        //All php files which do not end with Test.php
        $iterator = new \RegexIterator(new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($root)), '/(?<!Test)\\.php$/');
        /* @var $fileInfo \SplFileInfo */
        foreach ($iterator as $fileInfo) {
            $content = file_get_contents($fileInfo->getRealPath());
            if (preg_match_all('/^.*?(?:config|config->get)\\([\\s\\R]*[\'"](scalr[\\w\\.]+)[\'"][\\s\\R]*\\).*$/m', $content, $m)) {
                foreach ($m[1] as $i => $constname) {
                    if (!isset($vars[$constname])) {
                        $vars[$constname] = array();
                    }
                    $vars[$constname][] = array('file' => str_replace(array($root . DIRECTORY_SEPARATOR, '\\'), array('', '/'), $fileInfo->getRealPath()), 'line' => trim($m[0][$i]));
                }
            }
        }
        return $vars;
    }