File tree Expand file tree Collapse file tree 4 files changed +19
-0
lines changed
Expand file tree Collapse file tree 4 files changed +19
-0
lines changed Original file line number Diff line number Diff line change 232232 'wp_nonce_field ' => [null , 'action ' => '-1|string ' ],
233233 'did_action ' => ['int<0, max> ' ],
234234 'get_current_blog_id ' => ['int<0, max> ' ],
235+ 'wp_extract_urls ' => ['($content is empty ? array{} : list<string>) ' ],
235236];
Original file line number Diff line number Diff line change @@ -57,6 +57,7 @@ public function dataFileAsserts(): iterable
5757 yield from $ this ->gatherAssertTypes (__DIR__ . '/data/wp_die.php ' );
5858 yield from $ this ->gatherAssertTypes (__DIR__ . '/data/wp_dropdown_languages.php ' );
5959 yield from $ this ->gatherAssertTypes (__DIR__ . '/data/wp_error_parameter.php ' );
60+ yield from $ this ->gatherAssertTypes (__DIR__ . '/data/wp_extract_urls.php ' );
6061 yield from $ this ->gatherAssertTypes (__DIR__ . '/data/wp_generate_tag_cloud.php ' );
6162 yield from $ this ->gatherAssertTypes (__DIR__ . '/data/wp_get_archives.php ' );
6263 yield from $ this ->gatherAssertTypes (__DIR__ . '/data/wp_get_post_categories.php ' );
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace PhpStubs \WordPress \Core \Tests ;
6+
7+ use function wp_extract_urls ;
8+ use function PHPStan \Testing \assertType ;
9+
10+ assertType ('array{} ' , wp_extract_urls ('' ));
11+
12+ assertType ('list<string> ' , wp_extract_urls ('content with no URLs ' ));
13+ assertType ('list<string> ' , wp_extract_urls ('content with one URL: https://example.com ' ));
14+ assertType ('list<string> ' , wp_extract_urls ('content with multiple URLs: https://example.com and http://another-example.com ' ));
15+
16+ assertType ('list<string> ' , wp_extract_urls (Faker::string ()));
Original file line number Diff line number Diff line change @@ -111116,6 +111116,7 @@ function xmlrpc_removepostdata($content)
111116111116 *
111117111117 * @param string $content Content to extract URLs from.
111118111118 * @return string[] Array of URLs found in passed string.
111119+ * @phpstan-return ($content is empty ? array{} : list<string>)
111119111120 */
111120111121 function wp_extract_urls($content)
111121111122 {
You can’t perform that action at this time.
0 commit comments