Exakat\Analyzer\Php\UnsetOrCast::analyze PHP Method

analyze() public method

public analyze ( )
    public function analyze()
    {
        $mapping = <<<GREMLIN
if (it.get().label() == "Cast") {
    x2 = "(unset)";
} else {
    x2 = "unset( )";
};
GREMLIN;
        $storage = array('(unset)' => '(unset)', 'unset( )' => 'unset( )');
        $this->atomIs(array('Functioncall', 'Cast'))->raw('or( hasLabel("Cast").has("token", "T_UNSET_CAST") , hasLabel("Functioncall").has("fullnspath", "\\\\unset"))')->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(array('Functioncall', 'Cast'))->raw('or( hasLabel("Cast").has("token", "T_UNSET_CAST") , hasLabel("Functioncall").has("fullnspath", "\\\\unset"))')->raw('sideEffect{ ' . $mapping . ' }')->raw('filter{ x2 in ' . $types . '}')->back('first');
        $this->prepareQuery();
    }
UnsetOrCast