Beispiel #1
0
 /**
  * Visit a node with kind `\ast\AST_NEW`
  *
  * @param Node $node
  * A node of the type indicated by the method name that we'd
  * like to figure out the type that it produces.
  *
  * @return UnionType
  * The set of types that are possibly produced by the
  * given node
  */
 public function visitNew(Node $node) : UnionType
 {
     $class_name = AST::classNameFromNode($this->context, $this->code_base, $node);
     if (empty($class_name)) {
         return ObjectType::instance()->asUnionType();
     }
     $class_fqsen = FullyQualifiedClassName::fromStringInContext($class_name, $this->context);
     if ($this->code_base->hasClassWithFQSEN($class_fqsen)) {
         return $this->code_base->getClassByFQSEN($class_fqsen)->getUnionType();
     }
     /*
     assert(false,
         "Class $class_fqsen not found at {$this->context}");
     */
     return ObjectType::instance()->asUnionType();
 }
Beispiel #2
0
 /**
  * Visit a node with kind `\ast\AST_NEW`
  *
  * @param Node $node
  * A node of the type indicated by the method name that we'd
  * like to figure out the type that it produces.
  *
  * @return UnionType
  * The set of types that are possibly produced by the
  * given node
  */
 public function visitNew(Node $node) : UnionType
 {
     try {
         $class_name = AST::classNameFromNode($this->context, $this->code_base, $node);
     } catch (TypeException $exception) {
         return ObjectType::instance()->asUnionType();
     }
     if (empty($class_name)) {
         return ObjectType::instance()->asUnionType();
     }
     $class_fqsen = FullyQualifiedClassName::fromStringInContext($class_name, $this->context);
     if ($this->code_base->hasClassWithFQSEN($class_fqsen)) {
         return $this->code_base->getClassByFQSEN($class_fqsen)->getUnionType();
     }
     return ObjectType::instance()->asUnionType();
 }