Skip to content

Commit 39a7667

Browse files
committed
Add a helper for getting the since value.
1 parent 407b652 commit 39a7667

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

src/Doc.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ public function getParams(): array {
5959
return $this->tags->getParams();
6060
}
6161

62+
public function getSince(): string {
63+
return $this->tags->getSince();
64+
}
65+
6266
public function getReturnTypeString(): ?string {
6367
return $this->tags->getReturnTypeString();
6468
}

src/Tags.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,22 @@ public function getParams(): array {
5555
return $this->getByType( 'param' );
5656
}
5757

58+
public function getSince(): string {
59+
foreach ( $this->tags as $tag ) {
60+
if ( $tag->getName() === 'since' ) {
61+
$since = $tag->getContent();
62+
63+
if ( strpos( $since, 'MU' ) !== false ) {
64+
$since = '3.0.0';
65+
}
66+
67+
return $since;
68+
}
69+
}
70+
71+
return '';
72+
}
73+
5874
/**
5975
* @return array<int, Tag>
6076
* @phpstan-return list<Tag>

tests/phpunit/HooksTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,15 @@ public function testCanCountParams(): void {
9191
self::assertSame( 2, $count );
9292
}
9393

94+
public function testCanGetSince(): void {
95+
$hooks = $this->getFilters();
96+
$hook = $hooks->find( 'wp_tag_cloud' );
97+
98+
$since = $hook->getDoc()->getSince();
99+
100+
self::assertSame( '2.3.0', $since );
101+
}
102+
94103
/**
95104
* @return array<string, array<int, string>>
96105
* @phpstan-return array{

0 commit comments

Comments
 (0)