public function leaveNode(PhpParser\Node $node)
 {
     // check for global function calls
     if ($node instanceof Expr\FuncCall && !$this->inGlobalScope()) {
         $dictionary = new Dictionary();
         $obj = new NodeWrapper($node);
         $functionName = $obj->getName();
         // skip internal php functions
         if ($dictionary->isInternalFunction($functionName)) {
             return;
         }
         $this->stack->addIssue(new GlobalFunctionCallIssue($node));
     }
 }
 public function leaveNode(PhpParser\Node $node)
 {
     // check for static method calls (ie: Things::doStuff())
     if ($node instanceof Expr\StaticCall && !$this->inGlobalScope()) {
         $obj = new NodeWrapper($node);
         $name = $obj->getName();
         list($className) = explode('::', $name);
         // only report static method calls for php classes that are
         // not safe for instantiation (ie: with external resources)
         $dictionary = new Dictionary();
         if (!$dictionary->isClassSafeForInstantiation($className)) {
             $this->stack->addIssue(new StaticMethodCallIssue($node));
         }
     }
 }
 public function leaveNode(PhpParser\Node $node)
 {
     if ($node instanceof Expr\ClassConstFetch && !$this->inGlobalScope()) {
         $parentClass = $this->stack->findContextOfType(new CollectionSpecification());
         $obj = new NodeWrapper($node);
         // check for class constant fetch from different
         // class (ie: OtherClass::property)
         if ($parentClass !== false) {
             if (!$obj->isSameClassAs($parentClass->getName())) {
                 $this->stack->addIssue(new ExternalClassConstantFetchIssue($node));
             }
         } else {
             $this->stack->addIssue(new ExternalClassConstantFetchIssue($node));
         }
     }
 }
 public function leaveNode(PhpParser\Node $node)
 {
     // check for "new" statements
     if ($node instanceof Expr\New_ && !$this->inGlobalScope() && !$this->insideThrow) {
         $parentClass = $this->stack->findContextOfType(new CollectionSpecification());
         if ($parentClass === false || stripos($parentClass->getName(), 'Factory') === FALSE) {
             $dictionary = new Dictionary();
             $obj = new NodeWrapper($node);
             // only report internal php classes if not safe for
             // instantiation (ie: with external resources)
             if (!$dictionary->isClassSafeForInstantiation($obj->getName())) {
                 $this->stack->addIssue(new NewInstanceIssue($node));
             }
         }
     } elseif ($node instanceof Stmt\Throw_) {
         $this->insideThrow = false;
     }
 }
 public final function __construct(PhpParser\Node $node)
 {
     $this->line = $node->getLine();
     $obj = new NodeWrapper($node);
     $this->id = $obj->getName();
 }