forked from php-stubs/wordpress-stubs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/master'
- Loading branch information
Showing
4 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PhpStubs\WordPress\Core\Tests; | ||
|
||
use function get_categories; | ||
use function PHPStan\Testing\assertType; | ||
|
||
// Default argument values (fields => all) | ||
assertType('array<int, WP_Term>', get_categories()); | ||
assertType('array<int, WP_Term>', get_categories([])); | ||
|
||
// Requesting a count | ||
assertType('list<numeric-string>', get_categories(['fields' => 'count'])); | ||
assertType('list<numeric-string>', get_categories(['foo' => 'bar','fields' => 'count'])); | ||
|
||
// Requesting names or slugs | ||
assertType('list<string>', get_categories(['fields' => 'names'])); | ||
assertType('list<string>', get_categories(['fields' => 'slugs'])); | ||
assertType('array<int, string>', get_categories(['fields' => 'id=>name'])); | ||
assertType('array<int, string>', get_categories(['fields' => 'id=>slug'])); | ||
|
||
// Requesting IDs | ||
assertType('list<int>', get_categories(['fields' => 'ids'])); | ||
assertType('list<int>', get_categories(['fields' => 'tt_ids'])); | ||
|
||
// Requesting parent IDs | ||
assertType('array<int, int>', get_categories(['fields' => 'id=>parent'])); | ||
|
||
// Requesting objects | ||
assertType('array<int, WP_Term>', get_categories(['fields' => 'all'])); | ||
assertType('array<int, WP_Term>', get_categories(['fields' => 'all_with_object_id'])); | ||
assertType('array<int, WP_Term>', get_categories(['fields' => 'foo'])); | ||
|
||
// Unknown fields value | ||
assertType('array<int, int|string|WP_Term>', get_categories(['fields' => (string)$_GET['fields']])); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters