-
-
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.
Merge remote-tracking branch 'upstream/master' into import-extensions
- Loading branch information
Showing
6 changed files
with
137 additions
and
1 deletion.
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,25 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PhpStubs\WordPress\Core\Tests; | ||
|
||
use function wp_die; | ||
use function PHPStan\Testing\assertType; | ||
|
||
// default (['exit' => true]) | ||
assertType('never', wp_die()); | ||
assertType('never', wp_die('')); | ||
assertType('never', wp_die('', '')); | ||
|
||
// explicit exit | ||
assertType('never', wp_die('', '', ['exit' => true])); | ||
assertType('null', wp_die('', '', ['exit' => false])); | ||
|
||
// unknonwn | ||
assertType('null', wp_die('', '', ['exit' => (bool)$_GET['exit']])); | ||
assertType('null', wp_die('', '', (array)$_GET['args'])); | ||
|
||
// non-array $args parameter ($args not string type per @phpstan-param) | ||
/** @var int $args */ | ||
assertType('never', wp_die('', '', $args)); |
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,69 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PhpStubs\WordPress\Core\Tests; | ||
|
||
use function wp_is_numeric_array; | ||
use function PHPStan\Testing\assertType; | ||
|
||
assertType('false', wp_is_numeric_array((string)$_GET['thing'])); | ||
assertType('false', wp_is_numeric_array((int)$_GET['thing'])); | ||
assertType('false', wp_is_numeric_array((bool)$_GET['value'])); | ||
assertType('false', wp_is_numeric_array(null)); | ||
|
||
assertType('true', wp_is_numeric_array([])); | ||
|
||
/** @var list<mixed> $value */ | ||
$value = $_GET['value']; | ||
assertType('true', wp_is_numeric_array($value)); | ||
|
||
/** @var array<int, mixed> $value */ | ||
$value = $_GET['value']; | ||
assertType('true', wp_is_numeric_array($value)); | ||
|
||
/** @var array<string, mixed> $value */ | ||
$value = $_GET['value']; | ||
assertType('false', wp_is_numeric_array($value)); | ||
|
||
/** @var array $value */ | ||
$value = $_GET['value']; | ||
assertType('bool', wp_is_numeric_array($value)); | ||
|
||
/** @var array<int|string, mixed> $value */ | ||
$value = $_GET['value']; | ||
assertType('bool', wp_is_numeric_array($value)); | ||
|
||
/** @var array<int|string, mixed> $value */ | ||
$value = $_GET['value']; | ||
assertType('bool', wp_is_numeric_array($value)); | ||
|
||
/** @var array{'key1': 'value1', 'key2': 'value2'} $value */ | ||
$value = $_GET['value']; | ||
assertType('false', wp_is_numeric_array($value)); | ||
|
||
/** @var array{0: 'value0', 1: 'value1'} $value */ | ||
$value = $_GET['value']; | ||
assertType('true', wp_is_numeric_array($value)); | ||
|
||
/** @var array{0: 'value0', key1: 'value1'} $value */ | ||
$value = $_GET['value']; | ||
assertType('bool', wp_is_numeric_array($value)); | ||
|
||
assertType('bool', wp_is_numeric_array($_GET['value'])); | ||
|
||
/** @var list<string>|string */ | ||
$value = $_GET['value']; | ||
if (wp_is_numeric_array($value)) { | ||
assertType('list<string>', $value); | ||
} | ||
|
||
/** @var array<int, string>|string */ | ||
$value = $_GET['value']; | ||
if (wp_is_numeric_array($value)) { | ||
assertType('array<int, string>', $value); | ||
} | ||
|
||
if (wp_is_numeric_array($_GET['value'])) { | ||
assertType('array<int, mixed>', $_GET['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,28 @@ | ||
<?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 wp_list_pages; | ||
use function PHPStan\Testing\assertType; | ||
|
||
// Default value of true | ||
assertType('null', wp_list_pages()); | ||
|
||
// Explicit value of true | ||
assertType('null', wp_list_pages(['echo' => true, 'key' => 'value'])); | ||
|
||
// Explicit value of false | ||
assertType('string', wp_list_pages(['echo' => false, 'key' => 'value'])); | ||
|
||
// Unknown value | ||
assertType('string|null', wp_list_pages(['echo' => (bool)$GET['echo'], '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