hasMethodWithName() public method

public hasMethodWithName ( CodeBase $code_base, string $name ) : boolean
$code_base Phan\CodeBase
$name string
return boolean True if this class has a method with the given name
示例#1
0
文件: Method.php 项目: tpunt/phan
 /**
  * @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;
 }