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
1 change: 1 addition & 0 deletions functionMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@
'wp_internal_hosts' => ['array<lowercase-string>'],
'wp_is_numeric_array' => ['($data is array<int, mixed> ? true : false)', '@phpstan-pure' => ''],
'wp_is_post_revision' => ['($post is \WP_Post ? false|int<0, max> : ($post is int<min, 0> ? false : false|int<0, max>))'],
'wp_is_stream' => [null, '@phpstan-assert-if-true' => '=non-falsy-string $path'],
'wp_is_uuid' => ['($version is 4|null ? bool : false)', 'uuid' => 'TUuid', 'version' => '4', '@phpstan-template TUuid' => 'of string', '@phpstan-assert-if-true' => '=TUuid&lowercase-string&non-falsy-string $uuid', '@phpstan-pure' => ''],
'wp_json_encode' => ['non-empty-string|false', 'depth' => 'int<1, max>'],
'wp_latest_comments_draft_or_post_title' => ['non-falsy-string'],
Expand Down
38 changes: 38 additions & 0 deletions tests/data/assert/wp-is-stream.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

declare(strict_types=1);

namespace PhpStubs\WordPress\Core\Tests;

use function wp_is_stream;
use function PHPStan\Testing\assertType;

// if wp_is_stream() returns true, then $path is a non-falsy string
// with no effect on the type of $path if it returns false

$path = Faker::string();
if (wp_is_stream($path)) {
assertType('non-falsy-string', $path);
}
assertType('string', $path);

$path = Faker::lowercaseString();
if (wp_is_stream($path)) {
assertType('lowercase-string&non-falsy-string', $path);
}
assertType('lowercase-string', $path);

// if wp_is_stream() returns false, $path is not narrowed
// with no effect on the type of $path if it returns true

$path = Faker::string();
if (! wp_is_stream($path)) {
assertType('string', $path);
}
assertType('string', $path);

$path = Faker::lowercaseString();
if (! wp_is_stream($path)) {
assertType('lowercase-string', $path);
}
assertType('lowercase-string', $path);
1 change: 1 addition & 0 deletions wordpress-stubs.php
Original file line number Diff line number Diff line change
Expand Up @@ -134583,6 +134583,7 @@ function _device_can_upload()
*
* @param string $path The resource path or URL.
* @return bool True if the path is a stream URL.
* @phpstan-assert-if-true =non-falsy-string $path
*/
function wp_is_stream($path)
{
Expand Down
Loading