Skip to content

Commit d79fabd

Browse files
committed
Mark trailingslashit as pure
1 parent 945a6da commit d79fabd

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

functionMap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@
155155
'the_date' => ['($display is true ? void : string)'],
156156
'the_modified_date' => ['($display is true ? void : string)'],
157157
'the_title' => ['($display is true ? void : string|void)'],
158-
'trailingslashit' => ['non-falsy-string'],
158+
'trailingslashit' => ['non-falsy-string', '@phpstan-pure' => ''],
159159
'urldecode_deep' => ['T', '@phpstan-template' => 'T', 'value' => 'T'],
160160
'urlencode_deep' => ['T', '@phpstan-template' => 'T', 'value' => 'T'],
161161
'validate_file' => ["(\$file is '' ? 0 : (\$allowed_files is empty ? 0|1|2 : 0|1|2|3))"],
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace PhpStubs\WordPress\Core\Tests;
6+
7+
use function trailingslashit;
8+
use function PHPStan\Testing\assertType;
9+
10+
$toSlash = Faker::string();
11+
12+
if (trailingslashit($toSlash) === 'foo') {
13+
assertType("'foo'", trailingslashit($toSlash));
14+
}
15+
16+
if (trailingslashit($toSlash) !== 'foo') {
17+
assertType('non-falsy-string', trailingslashit($toSlash));
18+
}

wordpress-stubs.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109593,6 +109593,7 @@ function backslashit($value)
109593109593
*
109594109594
* @param string $value Value to which trailing slash will be added.
109595109595
* @return string String with trailing slash added.
109596+
* @phpstan-pure
109596109597
* @phpstan-return non-falsy-string
109597109598
*/
109598109599
function trailingslashit($value)

0 commit comments

Comments
 (0)