Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion functionMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
'register_post_type' => [null, 'post_type' => 'lowercase-string&non-empty-string'],
'render_block_core_categories' => ['non-falsy-string'],
'rest_authorization_required_code' => ['401|403'],
'rest_sanitize_boolean' => ["(T is bool ? T : (T is ''|'false'|'FALSE'|'0'|0 ? false : true))", '@phpstan-template T' => 'of bool|string|int', 'value' => 'T'],
'rest_sanitize_boolean' => ["(T is bool ? T : (T is ''|'false'|'FALSE'|'0'|0 ? false : true))", '@phpstan-template T' => 'of bool|string|int', 'value' => 'T', '@phpstan-pure' => ''],
'rest_ensure_response' => ['($response is \WP_Error ? \WP_Error : \WP_REST_Response)'],
'sanitize_bookmark_field' => ['array<int, int>|int|string', 'field' => "'link_id'|'link_url'|'link_name'|'link_image'|'link_target'|'link_description'|'link_visible'|'link_owner'|'link_rating'|'link_updated'|'link_rel'|'link_notes'|'link_rss'|'link_category'"],
'sanitize_category' => ['T', '@phpstan-template' => 'T of array|object', 'category' => 'T'],
Expand Down
20 changes: 20 additions & 0 deletions tests/data/pure/rest-sanitize-boolean.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

namespace PhpStubs\WordPress\Core\Tests;

use function rest_sanitize_boolean;
use function PHPStan\Testing\assertType;

$toSanitize = Faker::mixed();

assertType('bool', rest_sanitize_boolean($toSanitize));

if (rest_sanitize_boolean($toSanitize)) {
assertType('true', rest_sanitize_boolean($toSanitize));
}

if (! rest_sanitize_boolean($toSanitize)) {
assertType('false', rest_sanitize_boolean($toSanitize));
}
1 change: 1 addition & 0 deletions wordpress-stubs.php
Original file line number Diff line number Diff line change
Expand Up @@ -135481,6 +135481,7 @@ function rest_is_ip_address($ip)
* @return bool Returns the proper associated boolean value.
* @phpstan-template T of bool|string|int
* @phpstan-param T $value
* @phpstan-pure
* @phpstan-return (T is bool ? T : (T is ''|'false'|'FALSE'|'0'|0 ? false : true))
*/
function rest_sanitize_boolean($value)
Expand Down
Loading