Skip to content

Commit 4f7c347

Browse files
authored
Stop excluding functions with callable parameter synopsis (#288)
1 parent b8d39e2 commit 4f7c347

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

generator/src/DocPage.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,17 @@ public function getMethodSynopsis(): array
163163
if ($file === false) {
164164
throw new \RuntimeException('An error occured while reading '.$this->path);
165165
}
166-
if (!preg_match_all('/<\/?methodsynopsis[\s\S]*?>[\s\S]*?<\/methodsynopsis>/m', $file, $functions, PREG_SET_ORDER, 0)) {
166+
167+
// Only evaluate the synopsis inside the `<refsect1 role="description">...</refsect1>` section of the doc page.
168+
// Other synopses might occur in the `<refsect1 role="parameters">...</refsect1>` section, but these describe
169+
// handlers, callbacks, and other callable-type arguments, not the function itself.
170+
preg_match_all('/<refsect1\s+role="description">[\s\S]*?<\/refsect1>/m', $file, $fileDescriptionSection);
171+
$fileDescriptionSection = implode('', $this->arrayFlatten((array) $fileDescriptionSection));
172+
173+
if (!preg_match_all('/<\/?methodsynopsis[\s\S]*?>[\s\S]*?<\/methodsynopsis>/m', $fileDescriptionSection, $functions, PREG_SET_ORDER, 0)) {
167174
return [];
168175
}
176+
169177
$functions = $this->arrayFlatten($functions);
170178
foreach ($functions as $function) {
171179
$cleaningFunction = \str_replace(['&false;', '&true;', '&null;'], ['false', 'true', 'null'], $function);

0 commit comments

Comments
 (0)