-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
functionMap: additions, improvement, corrections (#127)
* Improve return type of get_comment() and get_post() * Add wpdb::get_row() to functions map * Add tests for wp_clear_scheduled_hook() * Add wpdb::get_results() to the functions map * Add get_bookmark() to function map * Add get_category() to function map * Add argument type to get_term() * Use fully qualified name * Add get_category_by_path() to function map * Remove types already added without function map * Add spaces around array assignment operator * Regenerate function map * Add trailing comma to last array item
- Loading branch information
Showing
11 changed files
with
173 additions
and
62 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,16 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PhpStubs\WordPress\Core\Tests; | ||
|
||
use function get_bookmark; | ||
use function PHPStan\Testing\assertType; | ||
|
||
/** @var \stdClass|int $bookmark */ | ||
$bookmark; | ||
|
||
assertType('stdClass|null', get_bookmark($bookmark)); | ||
assertType('stdClass|null', get_bookmark($bookmark, 'OBJECT')); | ||
assertType('array<string, mixed>|null', get_bookmark($bookmark, 'ARRAY_A')); | ||
assertType('array<int, mixed>|null', get_bookmark($bookmark, 'ARRAY_N')); |
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,24 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PhpStubs\WordPress\Core\Tests; | ||
|
||
use function get_category; | ||
use function PHPStan\Testing\assertType; | ||
|
||
/** @var object $category */ | ||
$category; | ||
|
||
assertType('WP_Term', get_category($category)); | ||
assertType('WP_Term', get_category($category, 'OBJECT')); | ||
assertType('array<string, mixed>', get_category($category, 'ARRAY_A')); | ||
assertType('array<int, mixed>', get_category($category, 'ARRAY_N')); | ||
|
||
/** @var int|object $category */ | ||
$category; | ||
|
||
assertType('WP_Error|WP_Term|null', get_category($category)); | ||
assertType('WP_Error|WP_Term|null', get_category($category, 'OBJECT')); | ||
assertType('array<string, mixed>|WP_Error|null', get_category($category, 'ARRAY_A')); | ||
assertType('array<int, mixed>|WP_Error|null', get_category($category, 'ARRAY_N')); |
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,16 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PhpStubs\WordPress\Core\Tests; | ||
|
||
use function get_category_by_path; | ||
use function PHPStan\Testing\assertType; | ||
|
||
/** @var bool $bool */ | ||
$bool; | ||
|
||
assertType('WP_Error|WP_Term|null', get_category_by_path('', $bool, )); | ||
assertType('WP_Error|WP_Term|null', get_category_by_path('', $bool, 'OBJECT')); | ||
assertType('array<string, mixed>|WP_Error|null', get_category_by_path('', $bool, 'ARRAY_A')); | ||
assertType('array<int, mixed>|WP_Error|null', get_category_by_path('', $bool, 'ARRAY_N')); |
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
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,12 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PhpStubs\WordPress\Core\Tests; | ||
|
||
use function wp_clear_scheduled_hook; | ||
use function PHPStan\Testing\assertType; | ||
|
||
assertType('int<0, max>|false', wp_clear_scheduled_hook('hook', [])); | ||
assertType('int<0, max>|false', wp_clear_scheduled_hook('hook', [], false)); | ||
assertType('int<0, max>|WP_Error', wp_clear_scheduled_hook('hook', [], true)); |
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,21 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PhpStubs\WordPress\Core\Tests; | ||
|
||
use wpdb; | ||
use function PHPStan\Testing\assertType; | ||
|
||
// wpdb::get_row() | ||
assertType('stdClass|void|null', wpdb::get_row()); | ||
assertType('stdClass|void|null', wpdb::get_row(null, 'OBJECT')); | ||
assertType('array<string, mixed>|void|null', wpdb::get_row(null, 'ARRAY_A')); | ||
assertType('array<int, mixed>|void|null', wpdb::get_row(null, 'ARRAY_N')); | ||
|
||
// wpdb::get_results() | ||
assertType('stdClass|null', wpdb::get_results()); | ||
assertType('stdClass|null', wpdb::get_results(null, 'OBJECT')); | ||
assertType('array<string, stdClass>|null', wpdb::get_results(null, 'OBJECT_K')); | ||
assertType('array<string, mixed>|null', wpdb::get_results(null, 'ARRAY_A')); | ||
assertType('array<int, mixed>|null', wpdb::get_results(null, 'ARRAY_N')); |
Oops, something went wrong.