getMethodByName() public method

public getMethodByName ( CodeBase $code_base, string $name ) : Method
$code_base Phan\CodeBase
$name string
return Method The method with the given name
Example #1
0
 /**
  * @return Method
  * A default constructor for the given class
  */
 public static function defaultConstructorForClassInContext(Clazz $clazz, Context $context, CodeBase $code_base) : Method
 {
     $method_fqsen = FullyQualifiedMethodName::make($clazz->getFQSEN(), '__construct');
     $method = new Method($context, '__construct', $clazz->getUnionType(), 0, $method_fqsen);
     if ($clazz->hasMethodWithName($code_base, $clazz->getName())) {
         $old_style_constructor = $clazz->getMethodByName($code_base, $clazz->getName());
         $method->setParameterList($old_style_constructor->getParameterList());
         $method->setNumberOfRequiredParameters($old_style_constructor->getNumberOfRequiredParameters());
         $method->setNumberOfOptionalParameters($old_style_constructor->getNumberOfOptionalParameters());
     }
     return $method;
 }