public function isVariadic() : bool { $isNativelyVariadic = $this->reflection->isVariadic(); if (!$isNativelyVariadic && $this->declaringClass->getName() === 'ReflectionMethod' && $this->reflection->getName() === 'invoke') { return true; } if (!$isNativelyVariadic && $this->declaringClass->getNativeReflection()->getFileName() !== false) { $key = sprintf('variadic-method-%s-%s-v2', $this->declaringClass->getName(), $this->reflection->getName()); $cachedResult = $this->cache->load($key); if ($cachedResult === null) { $nodes = $this->parser->parseFile($this->declaringClass->getNativeReflection()->getFileName()); $result = $this->callsFuncGetArgs($nodes); $this->cache->save($key, $result); return $result; } return $cachedResult; } return $isNativelyVariadic; }
private function generateMethodParameters(\ReflectionMethod $method) { $params = array(); $parameters = $method->getParameters(); foreach ($parameters as $i => $param) { $typeHint = $this->generateTypeHint($param); $defaultValue = $this->generateDefaultValue($param); if ($i + 1 == count($parameters) && $method->isVariadic()) { $typeHint .= ' ...'; $defaultValue = ''; } $params[] = $typeHint . $this->generateReferenceToken($param) . '$' . $param->getName() . $defaultValue; } return $params; }