From de5e7f123212b346e040033cfa69b83062d40ef2 Mon Sep 17 00:00:00 2001 From: tomirons Date: Wed, 6 Mar 2024 07:54:39 -0500 Subject: [PATCH] add doc block parser --- src/Processors/DocBlockProcessor.php | 41 ++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/Processors/DocBlockProcessor.php diff --git a/src/Processors/DocBlockProcessor.php b/src/Processors/DocBlockProcessor.php new file mode 100644 index 0000000..9ff3b61 --- /dev/null +++ b/src/Processors/DocBlockProcessor.php @@ -0,0 +1,41 @@ +getDocComment(); + $tokens = new TokenIterator($lexer->tokenize($comment)); + $phpDocNode = $parser->parse($tokens); + + foreach ($phpDocNode->children as $child) { + if ($child instanceof PhpDocTextNode) { + $description .= ' '.$child->text; + } + } + + return Str::squish($description); + } catch (Throwable $e) { + return ''; + } + } +}