Skip to content

Commit

Permalink
fix: Fix doc generator (#2409)
Browse files Browse the repository at this point in the history
  • Loading branch information
dwsupplee authored Oct 14, 2019
1 parent 862fb9c commit fbb01fc
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions dev/src/DocGenerator/Parser/CodeParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,7 @@ private function getExternalDepVersion($type, $external)
private function buildInternalLink($content)
{
$componentId = null;
$content = trim($content, '\\');
$ref = $this->getClassReference($content);
$fileName = $ref->getFileName();

Expand All @@ -852,7 +853,6 @@ private function buildInternalLink($content)
$componentId = $composer['extra']['component']['id'];
}

$content = trim($content, '\\');
$parts = explode('::', $content);
$type = $this->fileNameToType($fileName);

Expand Down Expand Up @@ -960,27 +960,25 @@ private function getClassReference($type)
// third party dependencies require type hints and throw a Parse error
// when an implementation is not compatible with its parent class or
// interface.
static $map = [
$unreflectableMap = [
// Monolog 1.x/2.x related classes
'Google\Cloud\Core\Logger\AppEngineFlexFormatter' => 'Core/src/Logger/AppEngineFlexFormatter.php',
'Google\Cloud\Core\Logger\AppEngineFlexFormatterV2' => 'Core/src/Logger/AppEngineFlexFormatterV2.php',
'Google\Cloud\Core\Logger\AppEngineFlexHandler' => 'Core/src/Logger/AppEngineFlexHandler.php',
'Google\Cloud\Core\Logger\AppEngineFlexHandlerV2' => 'Core/src/Logger/AppEngineFlexHandlerV2.php',
];
static $reflectedMap = [];

if (array_key_exists($type, $map)) {
return new ClassReference($type, $this->projectRoot.'/'.$map[$type]);
}

foreach ($map as $key => $value) {
if (strpos($type, $key) !== false) {
return new ClassReference($type, $this->projectRoot.'/'.$value);
}
if (array_key_exists($type, $unreflectableMap)) {
return new ClassReference($type, $this->projectRoot . $unreflectableMap[$type]);
} elseif (array_key_exists($type, $reflectedMap)) {
return new ClassReference($type, $reflectedMap[$type]);
}

$map[$type] = $this->getReflectionClass($type)->getFileName();
$reflectedMap[$type] = $this->getReflectionClass($type)
->getFileName();

return new ClassReference($type, $this->projectRoot.'/'.$map[$type]);
return new ClassReference($type, $reflectedMap[$type]);
}

private function getReflectionClass($type)
Expand Down

0 comments on commit fbb01fc

Please sign in to comment.