Skip to content

Commit

Permalink
fix stan
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinDev committed Nov 12, 2023
1 parent ad7b857 commit 940fc40
Showing 1 changed file with 7 additions and 5 deletions.
Expand Up @@ -10,6 +10,10 @@ public function __construct(private readonly bool $addLink = true)

public function run(string $extensionClassName): string
{
if (! class_exists($extensionClassName)) {
throw new \Exception();
}

$reflectionClass = new \ReflectionClass($extensionClassName);
$methods = $reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC);
$phpDoc = '';
Expand All @@ -26,7 +30,7 @@ public function run(string $extensionClassName): string

if ($parameter->isDefaultValueAvailable()) {
$defaultValue = $parameter->getDefaultValue();
$paramString .= ' = '.str_replace(\chr(10), '', var_export($defaultValue, true));
$paramString .= ' = '.str_replace("\n", '', var_export($defaultValue, true));
}

$paramStrings[] = $paramString;
Expand All @@ -37,7 +41,7 @@ public function run(string $extensionClassName): string
$phpDoc .= ' * @method '.('' === $returnType ? '' : $returnType.' ').$method->getName().'('.implode(', ', $paramStrings).')';
if ($this->addLink) {
$phpDoc .= "\n".' * '
.ltrim(str_replace(preg_replace('#/vendor/.+$#', '', __DIR__), '', $reflectionClass->getFileName()), '/')
.ltrim(str_replace(\Safe\preg_replace('#/vendor/.+$#', '', __DIR__), '', $reflectionClass->getFileName() ?: ''), '/')
.':'.$method->getStartLine()
."\n".' * ';
}
Expand All @@ -54,7 +58,7 @@ private function formatType(\ReflectionType|null $returnType): string
}

if ($returnType instanceof \ReflectionNamedType) {
return false === $returnType?->isBuiltin() ?
return false === $returnType->isBuiltin() ?
(($returnType->allowsNull() ? '?' : '').'\\'.$returnType->getName())
: $returnType;
}
Expand All @@ -68,8 +72,6 @@ private function formatType(\ReflectionType|null $returnType): string
return implode('|', $toReturn);
}

dd($returnType);

throw new \Exception();
}
}

0 comments on commit 940fc40

Please sign in to comment.