Skip to content

Commit 66ee578

Browse files
committed
fix crash on broken API links
fixes #149
1 parent 6ee64b6 commit 66ee578

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Yii Framework 2 apidoc extension Change Log
44
2.1.1 under development
55
-----------------------
66

7+
- Bug #149: Fixed crash on wrongly formatted API links (cebe, santosh-1265)
78
- Enh #38: Fixed display of default values given as octal or hex notation (hiqsol)
89
- Enh: Display TOC only if there is more than one headline (cebe)
910
- Enh: Extracted markdown code highlighting to a trait `MarkdownHighlightTrait` (cebe)

helpers/ApiMarkdownTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ protected function parseApiLinks($text)
4141
}
4242
/** @var $type TypeDoc */
4343
$type = static::$renderer->apiContext->getType($typeName);
44-
if ($type === null) {
44+
if ($type === null || $subjectName === '') {
4545
static::$renderer->apiContext->errors[] = [
4646
'file' => ($context !== null) ? $context->sourceFile : null,
4747
'message' => 'broken link to ' . $typeName . '::' . $subjectName . (($context !== null) ? ' in ' . $context->name : ''),

models/TypeDoc.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,17 @@ class TypeDoc extends BaseDoc
5454
*/
5555
public function findSubject($subjectName)
5656
{
57-
if ($subjectName[0] != '$') {
57+
if (empty($subjectName)) {
58+
return null;
59+
}
60+
if ($subjectName[0] !== '$') {
5861
foreach ($this->methods as $name => $method) {
5962
if (rtrim($subjectName, '()') == $name) {
6063
return $method;
6164
}
6265
}
6366
}
64-
if (!empty($subjectName) && substr_compare($subjectName, '()', -2, 2) === 0) {
67+
if (substr_compare($subjectName, '()', -2, 2) === 0) {
6568
return null;
6669
}
6770
if ($this->properties === null) {

0 commit comments

Comments
 (0)