Skip to content

Commit 32830bb

Browse files
committed
More types for PHPStan.
1 parent eed8cc3 commit 32830bb

File tree

6 files changed

+17
-1
lines changed

6 files changed

+17
-1
lines changed

src/Doc.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public function getTags(): Tags {
6060

6161
/**
6262
* @return array<int, Tag>
63+
* @phpstan-return list<Tag>
6364
*/
6465
public function getParams(): array {
6566
return $this->getTags()->getParams();

src/Hook.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ public function getArgs(): int {
8585

8686
/**
8787
* @return array<int, Tag>
88+
* @phpstan-return list<Tag>
8889
*/
8990
public function getParams(): array {
9091
return $this->getDoc()->getParams();

src/Hooks.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,15 @@ public function getIterator(): \Generator {
5757

5858
/**
5959
* @return array<int, Hook>
60+
* @phpstan-return list<Hook>
6061
*/
6162
public function all(): array {
6263
return iterator_to_array( $this );
6364
}
6465

6566
/**
6667
* @return array<int, Hook>
68+
* @phpstan-return list<Hook>
6769
*/
6870
public function filter( string $search ): array {
6971
$hooks = [];

src/Tag.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @phpstan-type TagArray array{
88
* name: string,
99
* content: string,
10-
* types?: array<int, string>,
10+
* types?: list<string>,
1111
* variable?: string,
1212
* link?: string,
1313
* refers?: string,
@@ -27,6 +27,7 @@ final class Tag {
2727

2828
/**
2929
* @var ?array<int, string>
30+
* @phpstan-var ?list<string>
3031
*/
3132
protected $types;
3233

src/Tags.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
final class Tags implements \Countable, \IteratorAggregate {
1212
/**
1313
* @var array<int, Tag>
14+
* @phpstan-var list<Tag>
1415
*/
1516
protected $tags;
1617

@@ -36,13 +37,15 @@ public function getIterator(): \Traversable {
3637

3738
/**
3839
* @return array<int, Tag>
40+
* @phpstan-return list<Tag>
3941
*/
4042
public function all(): array {
4143
return iterator_to_array( $this );
4244
}
4345

4446
/**
4547
* @return array<int, Tag>
48+
* @phpstan-return list<Tag>
4649
*/
4750
public function getParams(): array {
4851
$params = [];

tests/phpunit/HooksTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ public function testFindByUnknownNameReturnsNull(): void {
5252

5353
/**
5454
* @return array<string, array<int, string>>
55+
* @phpstan-return array{
56+
* actions: list<string>,
57+
* filters: list<string>,
58+
* }
5559
*/
5660
public function dataCoreVendorPaths(): array {
5761
$dir = dirname( __DIR__, 2 );
@@ -72,6 +76,10 @@ public function dataCoreVendorPaths(): array {
7276

7377
/**
7478
* @return array<string, array<int, string>>
79+
* @phpstan-return array{
80+
* actions: list<string>,
81+
* filters: list<string>,
82+
* }
7583
*/
7684
public function dataCoreFiles(): array {
7785
$dir = dirname( __DIR__, 2 ) . '/vendor/wp-hooks/wordpress-core/hooks';

0 commit comments

Comments
 (0)