示例#1
0
 /**
  * @return Method[]
  */
 public static function methodListFromReflectionClassAndMethod(Context $context, CodeBase $code_base, \ReflectionClass $class, \ReflectionMethod $reflection_method) : array
 {
     $reflection_method = new \ReflectionMethod($class->getName(), $reflection_method->name);
     $method = new Method($context, $reflection_method->name, new UnionType(), $reflection_method->getModifiers());
     $method->setNumberOfRequiredParameters($reflection_method->getNumberOfRequiredParameters());
     $method->setNumberOfOptionalParameters($reflection_method->getNumberOfParameters() - $reflection_method->getNumberOfRequiredParameters());
     $method->setFQSEN(FullyQualifiedMethodName::fromStringInContext($method->getName(), $context));
     return self::functionListFromFunction($method, $code_base);
 }
示例#2
0
文件: Method.php 项目: themarios/phan
 /**
  * @return Method[]
  * One or more (alternate) methods begotten from
  * reflection info and internal method data
  */
 public static function methodListFromReflectionFunction(CodeBase $code_base, \ReflectionFunction $reflection_function) : array
 {
     $number_of_required_parameters = $reflection_function->getNumberOfRequiredParameters();
     $number_of_optional_parameters = $reflection_function->getNumberOfParameters() - $number_of_required_parameters;
     $context = new Context();
     $parts = explode('\\', $reflection_function->getName());
     $method_name = array_pop($parts);
     $namespace = '\\' . implode('\\', $parts);
     $fqsen = FullyQualifiedFunctionName::make($namespace, $method_name);
     $method = new Method($context, $fqsen->getName(), new UnionType(), 0, $number_of_required_parameters, $number_of_optional_parameters);
     $method->setFQSEN($fqsen);
     return self::methodListFromMethod($method, $code_base);
 }
示例#3
0
文件: Method.php 项目: ablyler/phan
 /**
  * @return Method
  * A default constructor for the given class
  */
 public static function defaultConstructorForClassInContext(Clazz $clazz, Context $context) : Method
 {
     $method = new Method($context, '__construct', $clazz->getUnionType(), 0);
     $method->setFQSEN(FullyQualifiedMethodName::make($clazz->getFQSEN(), '__construct'));
     return $method;
 }
示例#4
0
文件: Method.php 项目: Jvbzephir/phan
 /**
  * @return Method[]
  * One or more (alternate) methods begotten from
  * reflection info and internal method data
  */
 public static function methodListFromSignature(CodeBase $code_base, FullyQualifiedFunctionName $fqsen, array $signature) : array
 {
     $context = new Context();
     $return_type = UnionType::fromStringInContext(array_shift($signature), $context);
     $method = new Method($context, $fqsen->getName(), $return_type, 0);
     $method->setFQSEN($fqsen);
     return self::methodListFromMethod($method, $code_base);
 }