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: 2 additions & 0 deletions functionMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
'add_users_page' => [null, 'callback' => "''|callable"],
'addslashes_gpc' => ['($gpc is string ? string : array)', '@phpstan-pure' => ''],
'antispambot' => [null, 'hex_encoding' => '0|1'],
'backslashit' => [null, '@phpstan-pure' => ''],
'block_version' => ["(\$content is '' ? 0 : 0|1)", '@phpstan-pure' => ''],
'bool_from_yn' => ["(\$yn is 'y' ? true : false)", '@phpstan-pure' => ''],
'build_dropdown_script_block_core_categories' => ['non-falsy-string'],
Expand Down Expand Up @@ -156,6 +157,7 @@
'the_modified_date' => ['($display is true ? void : string)'],
'the_title' => ['($display is true ? void : string|void)'],
'trailingslashit' => ['non-falsy-string', '@phpstan-pure' => ''],
'untrailingslashit' => [null, '@phpstan-pure' => ''],
'urldecode_deep' => ['T', '@phpstan-template' => 'T', 'value' => 'T'],
'urlencode_deep' => ['T', '@phpstan-template' => 'T', 'value' => 'T'],
'validate_file' => ["(\$file is '' ? 0 : (\$allowed_files is empty ? 0|1|2 : 0|1|2|3))"],
Expand Down
18 changes: 18 additions & 0 deletions tests/data/pure/backslashit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

namespace PhpStubs\WordPress\Core\Tests;

use function backslashit;
use function PHPStan\Testing\assertType;

$value = Faker::string();

if (backslashit($value) === 'foo') {
assertType("'foo'", backslashit($value));
}

if (backslashit($value) !== 'foo') {
assertType('string', backslashit($value));
}
18 changes: 18 additions & 0 deletions tests/data/pure/untrailingslashit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

namespace PhpStubs\WordPress\Core\Tests;

use function untrailingslashit;
use function PHPStan\Testing\assertType;

$value = Faker::string();

if (untrailingslashit($value) === 'foo') {
assertType("'foo'", untrailingslashit($value));
}

if (untrailingslashit($value) !== 'foo') {
assertType('string', untrailingslashit($value));
}
2 changes: 2 additions & 0 deletions wordpress-stubs.php
Original file line number Diff line number Diff line change
Expand Up @@ -109576,6 +109576,7 @@ function zeroise($number, $threshold)
*
* @param string $value Value to which backslashes will be added.
* @return string String with backslashes inserted.
* @phpstan-pure
*/
function backslashit($value)
{
Expand Down Expand Up @@ -109609,6 +109610,7 @@ function trailingslashit($value)
*
* @param string $value Value from which trailing slashes will be removed.
* @return string String without the trailing slashes.
* @phpstan-pure
*/
function untrailingslashit($value)
{
Expand Down