Exakat\Analyzer\Classes\UsedClass::analyze PHP Метод

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

public analyze ( )
    public function analyze()
    {
        $new = $this->query(<<<GREMLIN
g.V().hasLabel("New").out("NEW").not(has("fullnspath", "")).values("fullnspath").unique()
GREMLIN
);
        // class used in a New
        if (!empty($new)) {
            $this->atomIs('Class')->savePropertyAs('fullnspath', 'classdns')->fullnspathIs($new);
            $this->prepareQuery();
        }
        // classed used in a extends
        $extends = $this->query(<<<GREMLIN
g.V().hasLabel("Class").out("EXTENDS", "IMPLEMENTS").not(has("fullnspath", "")).values("fullnspath").unique()
GREMLIN
);
        if (!empty($extends)) {
            $this->atomIs('Class')->savePropertyAs('fullnspath', 'classdns')->fullnspathIs($extends);
            $this->prepareQuery();
        }
        // class used in static property
        $staticproperties = $this->query(<<<GREMLIN
g.V().hasLabel("Staticproperty", "Staticconstant", "Staticmethodcall", "Instanceof").out("CLASS").not(has("fullnspath", "")).values("fullnspath").unique()
GREMLIN
);
        if (!empty($staticproperties)) {
            $this->atomIs('Class')->savePropertyAs('fullnspath', 'classdns')->fullnspathIs($staticproperties);
            $this->prepareQuery();
        }
        // class used in a typehint
        $typehints = $this->query(<<<GREMLIN
g.V().hasLabel("Function").out("ARGUMENTS").out("ARGUMENT").out("TYPEHINT").not(has("fullnspath", "")).values("fullnspath").unique()
GREMLIN
);
        if (!empty($typehints)) {
            $this->atomIs('Class')->savePropertyAs('fullnspath', 'classdns')->fullnspathIs($typehints);
            $this->prepareQuery();
        }
        // class used in a Use
        $uses = $this->query(<<<GREMLIN
g.V().hasLabel("Use").out("USE").values("origin").unique()
GREMLIN
);
        if (!empty($uses)) {
            $this->atomIs('Class')->fullnspathIs($uses);
            $this->prepareQuery();
        }
        // class used in a String (full string only)
        $strings = $this->query(<<<GREMLIN
g.V().hasLabel("String").has("token", "T_CONSTANT_ENCAPSED_STRING")
     .where( __.in("ARGUMENT").in("ARGUMENTS").has("fullnspath", "\\\\array").count().is(eq(0)) )
     .filter{ it.get().value("noDelimiter").length() < 100}.filter{ it.get().value("noDelimiter").length() > 0}
     .filter{ !(it.get().value("noDelimiter") =~ /[^a-zA-Z0-9_-ÿ]/)}
     .map{ it.get().value("noDelimiter").toLowerCase(); }.unique()
GREMLIN
);
        $this->atomIs('Class')->outIs('NAME')->codeIs($strings)->back('first');
        $this->prepareQuery();
        // class used in a String (string with ::)
        $strings = $this->query(<<<GREMLIN
g.V().hasLabel("String").filter{ (it.get().value("noDelimiter") =~ "::" ).getCount() == 1 }
                        .where( __.in("ANALYZED").has("analyzer", "Functions/MarkCallable") )
                        .map{ it.get().value("noDelimiter").substring(0, it.get().value("noDelimiter").indexOf("::") );}.unique();
GREMLIN
);
        $strings = $this->makeFullnspath($strings);
        if (!empty($strings)) {
            $this->atomIs('Class')->fullnspathIs($strings)->back('first');
            $this->prepareQuery();
        }
        // class used in an array
        $arrays = $this->query(<<<GREMLIN
g.V().hasLabel("Functioncall").out("ARGUMENTS").out("ARGUMENT")
        .hasLabel("Functioncall").has("fullnspath", "\\\\array")
        .out("ARGUMENTS").where( __.in("ANALYZED").has("analyzer", "Functions/MarkCallable").count().is(eq(1)) )
        .has("count", 2).out("ARGUMENT").has("rank", 0).values("noDelimiter").unique()
GREMLIN
);
        $arrays = $this->makeFullnspath($arrays);
        if (!empty($arrays)) {
            $this->atomIs('Class')->fullnspathIs($arrays)->back('first');
            $this->prepareQuery();
        }
    }