defaultConstructorForClassInContext() public static method

public static defaultConstructorForClassInContext ( Clazz $clazz, Context $context, CodeBase $code_base ) : Method
$clazz Clazz
$context Phan\Language\Context
$code_base Phan\CodeBase
return Method A default constructor for the given class
Example #1
0
 /**
  * @return Method
  * The method with the given name
  */
 public function getMethodByNameInContext(CodeBase $code_base, string $name, Context $context) : Method
 {
     $method_fqsen = FullyQualifiedMethodName::make($this->getFQSEN(), $name);
     if (!$code_base->hasMethod($method_fqsen)) {
         if ('__construct' === $name) {
             // Create a default constructor if its requested
             // but doesn't exist yet
             $default_constructor = Method::defaultConstructorForClassInContext($this, $this->getContext()->withClassFQSEN($this->getFQSEN()));
             $this->addMethod($code_base, $default_constructor);
             return $default_constructor;
         }
         throw new CodeBaseException("Method with name {$name} does not exist for class {$this->getFQSEN()}.");
     }
     return $code_base->getMethod($method_fqsen);
 }