-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add cond. return type for paginate_links() (#226)
- Loading branch information
Showing
4 changed files
with
38 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,35 @@ | ||
<?php | ||
|
||
/** | ||
* Note: | ||
* Starting from PHPStan 1.10.49, void types, including void in unions, are | ||
* transformed into null. | ||
* | ||
* @link https://github.com/phpstan/phpstan-src/pull/2778 | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PhpStubs\WordPress\Core\Tests; | ||
|
||
use function paginate_links; | ||
use function PHPStan\Testing\assertType; | ||
|
||
/** @var negative-int $negInt */ | ||
$negInt = $_GET['negInt']; | ||
|
||
// Returns void | ||
assertType('null', paginate_links(['total' => $negInt, 'key' => 'value'])); | ||
assertType('null', paginate_links(['total' => 0, 'key' => 'value'])); | ||
assertType('null', paginate_links(['total' => 1, 'key' => 'value'])); | ||
|
||
// Returns list | ||
assertType('list<string>', paginate_links(['type' => 'array', 'key' => 'value'])); | ||
|
||
// Returns string | ||
assertType('string', paginate_links(['type' => 'plain', 'key' => 'value'])); | ||
assertType('string', paginate_links(['type' => 'list', 'key' => 'value'])); | ||
assertType('string', paginate_links(['type' => 'thing', 'key' => 'value'])); | ||
|
||
// Returns string by default | ||
assertType('string', paginate_links(['key' => 'value'])); |
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