Example #1
0
 /**
  * @return null
  * Analyze the node associated with this object
  * in the given context
  */
 public function analyze(Context $context, CodeBase $code_base) : Context
 {
     // Don't do anything if we care about being
     // fast
     if (Config::get()->quick_mode) {
         return $context;
     }
     if (!$this->hasNode()) {
         return $context;
     }
     // Closures depend on the context surrounding them such
     // as for getting `use(...)` variables. Since we don't
     // have them, we can't re-analyze them until we change
     // that.
     //
     // TODO: Store the parent context on Analyzable objects
     if ($this->getNode()->kind === \ast\AST_CLOSURE) {
         return $context;
     }
     // Don't go deeper than one level in
     if ($this->recursion_depth++ > 2) {
         return $context;
     }
     // Analyze the node in a cloned context so that we
     // don't overwrite anything
     $context = Analysis::analyzeNodeInContext($code_base, clone $context, $this->getNode());
     return $context;
 }