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 @@ -54,6 +54,7 @@
'add_theme_page' => [null, 'callback' => "''|callable"],
'add_users_page' => [null, 'callback' => "''|callable"],
'addslashes_gpc' => ['($gpc is string ? string : array)', '@phpstan-pure' => ''],
'antispambot' => [null, 'hex_encoding' => '0|1'],
'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
14 changes: 14 additions & 0 deletions tests/ParameterTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,20 @@ public function testAddShortcode(): void
);
}

public function testAntispambot(): void
{
$this->analyse(
__DIR__ . '/data/param/antispambot.php',
[
['Parameter #2 $hex_encoding of function antispambot expects 0|1, 42 given.', 12],
['Parameter #2 $hex_encoding of function antispambot expects 0|1, -42 given.', 13],
['Parameter #2 $hex_encoding of function antispambot expects 0|1, string given.', 14],
// Maybes
['Parameter #2 $hex_encoding of function antispambot expects 0|1, int given.', 17],
]
);
}

public function testBookmarks(): void
{
$field = "'link_category'|'link_description'|'link_id'|'link_image'|'link_name'|'link_notes'|'link_owner'|'link_rating'|'link_rel'|'link_rss'|'link_target'|'link_updated'|'link_url'|'link_visible'";
Expand Down
21 changes: 21 additions & 0 deletions tests/data/param/antispambot.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

namespace PhpStubs\WordPress\Core\Tests;

use function antispambot;

$email = Faker::string();

// Incorrect $hex_encoding
antispambot($email, 42);
antispambot($email, -42);
antispambot($email, Faker::string());

// Maybe incorrect $hex_encoding
antispambot($email, Faker::int());

// Correct $hex_encoding
antispambot($email, 0);
antispambot($email, 1);
1 change: 1 addition & 0 deletions wordpress-stubs.php
Original file line number Diff line number Diff line change
Expand Up @@ -109704,6 +109704,7 @@ function urldecode_deep($value)
* @param string $email_address Email address.
* @param int $hex_encoding Optional. Set to 1 to enable hex encoding.
* @return string Converted email address.
* @phpstan-param 0|1 $hex_encoding
*/
function antispambot($email_address, $hex_encoding = 0)
{
Expand Down