-
-
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.
Merge remote-tracking branch 'upstream/master' into import-extensions
- Loading branch information
Showing
10 changed files
with
200 additions
and
27 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
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,28 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PhpStubs\WordPress\Core\Tests; | ||
|
||
use function wp_generate_tag_cloud; | ||
use function PHPStan\Testing\assertType; | ||
|
||
/** @var array<\WP_Term> $args */ | ||
$tags = $_GET['tags']; | ||
|
||
// Default $args['format] value. | ||
assertType('string', wp_generate_tag_cloud($tags)); | ||
assertType('string', wp_generate_tag_cloud($tags, [])); | ||
|
||
// Requesting array | ||
assertType('array<int, string>', wp_generate_tag_cloud($tags, ['format' => 'array', 'key' => 'value'])); | ||
|
||
// Requesting string | ||
assertType('string', wp_generate_tag_cloud($tags, ['format' => 'list', 'key' => 'value'])); | ||
assertType('string', wp_generate_tag_cloud($tags, ['format' => 'flat', 'key' => 'value'])); | ||
|
||
// Unexpected $args['format] value | ||
assertType('string', wp_generate_tag_cloud($tags, ['format' => 'unexpected', 'key' => 'value'])); | ||
|
||
// Unknown $args['format] value | ||
assertType('array<int, string>|string', wp_generate_tag_cloud($tags, ['format' => (string)$_GET['format'], '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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?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 PHPStan\Testing\assertType; | ||
use function wp_tag_cloud; | ||
|
||
// Default value | ||
assertType('null', wp_tag_cloud()); | ||
|
||
// Echo true | ||
assertType('null', wp_tag_cloud(['echo' => true])); | ||
assertType('null', wp_tag_cloud(['format' => 'flat', 'echo' => true])); | ||
assertType('null', wp_tag_cloud(['format' => 'list', 'echo' => true])); | ||
assertType('null', wp_tag_cloud(['format' => 'unexpected', 'echo' => true])); | ||
|
||
// Echo true, but format (maybe) array | ||
assertType('array<int, string>|null', wp_tag_cloud(['format' => 'array', 'echo' => true])); | ||
assertType('array<int, string>|null', wp_tag_cloud(['format' => (string)$_GET['format'], 'echo' => true])); | ||
|
||
// Echo false | ||
assertType('string|null', wp_tag_cloud(['echo' => false])); | ||
assertType('string|null', wp_tag_cloud(['format' => 'flat', 'echo' => false])); | ||
assertType('string|null', wp_tag_cloud(['format' => 'list', 'echo' => false])); | ||
assertType('array<int, string>|null', wp_tag_cloud(['format' => 'array', 'echo' => false])); | ||
assertType('string|null', wp_tag_cloud(['format' => 'unexpected', 'echo' => false])); | ||
assertType('array<int, string>|string|null', wp_tag_cloud(['format' => (string)$_GET['format'], 'echo' => false])); | ||
|
||
// Echo unknown | ||
/** @var bool|0|1 $echo */ | ||
$boolZeroOne = $_GET['echo']; | ||
|
||
assertType('string|null', wp_tag_cloud(['echo' => $boolZeroOne])); | ||
assertType('string|null', wp_tag_cloud(['format' => 'flat', 'echo' => $boolZeroOne])); | ||
assertType('string|null', wp_tag_cloud(['format' => 'list', 'echo' => $boolZeroOne])); | ||
assertType('array<int, string>|null', wp_tag_cloud(['format' => 'array', 'echo' => $boolZeroOne])); | ||
assertType('string|null', wp_tag_cloud(['format' => 'unexpected', 'echo' => $boolZeroOne])); | ||
assertType('array<int, string>|string|null', wp_tag_cloud(['format' => (string)$_GET['format'], 'echo' => $boolZeroOne])); |
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,24 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PhpStubs\WordPress\Core\Tests; | ||
|
||
use function PHPStan\Testing\assertType; | ||
|
||
/** @var \WP_Translations */ | ||
$translations = $_GET['translations']; | ||
|
||
$string = (string)$_GET['string']; | ||
$singular = $_GET['singular'] ? $string : null; | ||
|
||
// WP_Translation::translate() | ||
assertType('null', $translations->translate(null)); | ||
assertType('string', $translations->translate($string)); | ||
|
||
// WP_Translation::translate_plural() | ||
assertType('null', $translations->translate_plural(null, null)); | ||
assertType('string', $translations->translate_plural($string, null)); | ||
assertType('null', $translations->translate_plural(null, $string)); | ||
assertType('string', $translations->translate_plural($string, $string)); | ||
assertType('string|null', $translations->translate_plural($singular, $string)); |
Oops, something went wrong.