Skip to content

Commit 692b12d

Browse files
committed
Merge branch 'master' into support-phpstan-syntax
2 parents 87768c3 + 90ddaa3 commit 692b12d

File tree

8 files changed

+460
-6
lines changed

8 files changed

+460
-6
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ Yii Framework 2 apidoc extension Change Log
44
3.0.9 under development
55
-----------------------
66

7-
- no changes in this release.
7+
- Bug #338: Fix deprecation error `Using null as an array offset is deprecated, use an empty string instead` (mspirkov)
8+
- Enh #337: Log invalid tags (mspirkov)
89

910

1011
3.0.8 November 24, 2025

models/BaseDoc.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use phpDocumentor\Reflection\DocBlock\Tag;
1212
use phpDocumentor\Reflection\DocBlock\Tags\Deprecated;
1313
use phpDocumentor\Reflection\DocBlock\Tags\Generic;
14+
use phpDocumentor\Reflection\DocBlock\Tags\InvalidTag;
1415
use phpDocumentor\Reflection\DocBlock\Tags\Since;
1516
use phpDocumentor\Reflection\DocBlock\Tags\Template;
1617
use phpDocumentor\Reflection\FqsenResolver;
@@ -287,6 +288,19 @@ public function __construct($parent = null, $reflector = null, $context = null,
287288
$this->psalmTypeImports[(string) $fqsen] = $psalmTypeImport;
288289
unset($this->tags[$i]);
289290
}
291+
} elseif ($tag instanceof InvalidTag && $context !== null) {
292+
$exception = $tag->getException();
293+
$message = 'Invalid tag: ' . $tag->render() . '.';
294+
295+
if ($exception !== null) {
296+
$message .= ' Exception message: ' . $exception->getMessage();
297+
}
298+
299+
$context->errors[] = [
300+
'line' => $this->startLine,
301+
'file' => $this->sourceFile,
302+
'message' => $message,
303+
];
290304
}
291305
}
292306

models/Context.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,8 @@ public function updateReferences()
113113
{
114114
// update all subclass references
115115
foreach ($this->classes as $class) {
116-
if ($class->parentClass === null) {
117-
continue;
118-
}
119-
120116
$className = $class->name;
121-
while (isset($this->classes[$class->parentClass])) {
117+
while ($class->parentClass !== null && isset($this->classes[$class->parentClass])) {
122118
$class = $this->classes[$class->parentClass];
123119
$class->subclasses[] = $className;
124120
}

tests/commands/ApiControllerTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,5 +100,15 @@ public function testGenerateBootstrap()
100100
$sourceFilesCount = count(FileHelper::findFiles($sourceFilesDir, ['recursive' => true]));
101101

102102
$this->assertSame($sourceFilesCount, $filesCount);
103+
104+
$warningsContent = file_get_contents("{$outputPath}/warnings.txt");
105+
// Remove the dynamic parts of the file paths
106+
$warningsContent = preg_replace('/(\s*\[file\] => ).*(\/tests\/.*\.php)/', '$1$2', $warningsContent);
107+
$this->assertMatchesTextSnapshot($warningsContent);
108+
109+
$errorsContent = file_get_contents("{$outputPath}/errors.txt");
110+
// Remove the dynamic parts of the file paths
111+
$errorsContent = preg_replace('/(\s*\[file\] => ).*(\/tests\/.*\.php)/', '$1$2', $errorsContent);
112+
$this->assertMatchesTextSnapshot($errorsContent);
103113
}
104114
}

0 commit comments

Comments
 (0)