-
-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
functionMap: additions, improvement, corrections #127
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
05d15e6
Improve return type of get_comment() and get_post()
IanDelMar 33a692c
Add wpdb::get_row() to functions map
IanDelMar 77c6834
Add tests for wp_clear_scheduled_hook()
IanDelMar f9a2644
Add wpdb::get_results() to the functions map
IanDelMar 8c4c4f1
Add get_bookmark() to function map
IanDelMar 91b2e0a
Add get_category() to function map
IanDelMar fb06106
Add argument type to get_term()
IanDelMar 0850d29
Use fully qualified name
IanDelMar f63e181
Add get_category_by_path() to function map
IanDelMar 489dbdc
Remove types already added without function map
IanDelMar f559915
Add spaces around array assignment operator
IanDelMar ec59da2
Regenerate function map
IanDelMar 02621e6
Add trailing comma to last array item
IanDelMar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't aware PHPStan supported this syntax for conditional return types, nice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Me neither. It's great! It helps to simplify some of the conditions and make them easier to read.