Skip to content

Commit 78608ae

Browse files
committed
Add helper methods for fetching hook parameters.
1 parent 026097a commit 78608ae

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/Hook.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,13 @@ public function getArgs(): int {
8383
return $this->args;
8484
}
8585

86+
/**
87+
* @return \Generator<int, Tag>
88+
*/
89+
public function getParams(): \Generator {
90+
yield from $this->getDoc()->getTags()->getParams();
91+
}
92+
8693
/**
8794
* @phpstan-param HookArray $data
8895
*/

src/Tags.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,18 @@ public function getIterator(): \Traversable {
3838
* @return array<int, Tag>
3939
*/
4040
public function all(): array {
41-
return $this->tags;
41+
return iterator_to_array( $this );
42+
}
43+
44+
/**
45+
* @return \Generator<int, Tag>
46+
*/
47+
public function getParams(): \Generator {
48+
foreach ( $this as $tag ) {
49+
if ( $tag->getName() === 'param' ) {
50+
yield $tag;
51+
}
52+
}
4253
}
4354

4455
/**

0 commit comments

Comments
 (0)