Skip to content

Commit

Permalink
Stop excluding functions with callable parameter synopsis (#288)
Browse files Browse the repository at this point in the history
  • Loading branch information
Duroth authored Aug 19, 2021
1 parent b8d39e2 commit 4f7c347
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion generator/src/DocPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,17 @@ public function getMethodSynopsis(): array
if ($file === false) {
throw new \RuntimeException('An error occured while reading '.$this->path);
}
if (!preg_match_all('/<\/?methodsynopsis[\s\S]*?>[\s\S]*?<\/methodsynopsis>/m', $file, $functions, PREG_SET_ORDER, 0)) {

// Only evaluate the synopsis inside the `<refsect1 role="description">...</refsect1>` section of the doc page.
// Other synopses might occur in the `<refsect1 role="parameters">...</refsect1>` section, but these describe
// handlers, callbacks, and other callable-type arguments, not the function itself.
preg_match_all('/<refsect1\s+role="description">[\s\S]*?<\/refsect1>/m', $file, $fileDescriptionSection);
$fileDescriptionSection = implode('', $this->arrayFlatten((array) $fileDescriptionSection));

if (!preg_match_all('/<\/?methodsynopsis[\s\S]*?>[\s\S]*?<\/methodsynopsis>/m', $fileDescriptionSection, $functions, PREG_SET_ORDER, 0)) {
return [];
}

$functions = $this->arrayFlatten($functions);
foreach ($functions as $function) {
$cleaningFunction = \str_replace(['&false;', '&true;', '&null;'], ['false', 'true', 'null'], $function);
Expand Down

0 comments on commit 4f7c347

Please sign in to comment.