Exakat\Analyzer\Php\GlobalsVsGlobal::analyze PHP Метод

analyze() публичный Метод

* Remove this if useless public function dependsOn() { return array('MethodDefinition'); }
public analyze ( )
    public function analyze()
    {
        $mapping = <<<GREMLIN
if (it.get().value('code') == '\$GLOBALS') { 
    x2 = 'GLOBALS'; 
} else {
    x2 = 'global'; 
}
GREMLIN;
        $storage = array('$GLOBALS' => 'GLOBALS', 'global' => 'global');
        $this->atomIs('Variable')->raw('or( has("code", "\\$GLOBALS"), __.in("GLOBAL")) ')->raw('map{ ' . $mapping . ' }')->raw('groupCount("gf").cap("gf").sideEffect{ s = it.get().values().sum(); }.next()');
        $types = (array) $this->rawQuery();
        $store = array();
        $total = 0;
        foreach ($storage as $key => $v) {
            $c = empty($types[$v]) ? 0 : $types[$v];
            $store[] = array('key' => $key, 'value' => $c);
            $total += $c;
        }
        Analyzer::$datastore->addRowAnalyzer($this->analyzerQuoted, $store);
        if ($total == 0) {
            return;
        }
        $types = array_filter($types, function ($x) use($total) {
            return $x > 0 && $x / $total < 0.1;
        });
        $types = '["' . str_replace('\\', '\\\\', implode('", "', array_keys($types))) . '"]';
        $this->atomIs('Variable')->raw('or( has("code", "\\$GLOBALS"), __.in("GLOBAL")) ')->raw('sideEffect{ ' . $mapping . ' }')->raw('filter{ x2 in ' . $types . '}')->back('first');
        $this->prepareQuery();
    }
GlobalsVsGlobal