Skip to content
4 changes: 4 additions & 0 deletions src/wp-admin/includes/media.php
Original file line number Diff line number Diff line change
Expand Up @@ -1237,6 +1237,8 @@ function image_align_input_fields( $post, $checked = '' ) {
* @param WP_Post $post
* @param bool|string $check
* @return array<string, string> An array of data for the image size input fields.
*
* @phpstan-return array{label: string, input: 'html', html: string}
*/
function image_size_input_fields( $post, $check = '' ) {
/**
Expand Down Expand Up @@ -1937,6 +1939,8 @@ function get_media_item( $attachment_id, $args = null ) {
* @param int $attachment_id
* @param array $args
* @return array<string, string> An array containing the media item and its metadata.
*
* @phpstan-return array{item: string, meta: string}
*/
function get_compat_media_markup( $attachment_id, $args = null ) {
$post = get_post( $attachment_id );
Expand Down
2 changes: 2 additions & 0 deletions src/wp-admin/includes/ms.php
Original file line number Diff line number Diff line change
Expand Up @@ -1187,6 +1187,8 @@ function network_edit_site_nav( $args = array() ) {
* @since 4.9.0
*
* @return array Help tab arguments.
*
* @phpstan-return array{id: non-falsy-string, title: string, content: non-falsy-string}
*/
function get_site_screen_help_tab_args() {
return array(
Expand Down
10 changes: 10 additions & 0 deletions src/wp-admin/includes/nav-menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -1348,6 +1348,16 @@ function wp_get_nav_menu_to_edit( $menu_id = 0 ) {
* @since 3.0.0
*
* @return string[] Array of column titles keyed by their column name.
*
* @phpstan-return array{
* _title: string,
* cb: non-falsy-string,
* link-target: string,
* title-attribute: string,
* css-classes: string,
* xfn: string,
* description: string,
* }
*/
function wp_nav_menu_manage_columns() {
return array(
Expand Down
2 changes: 2 additions & 0 deletions src/wp-admin/includes/post.php
Original file line number Diff line number Diff line change
Expand Up @@ -1220,6 +1220,8 @@ function _fix_attachment_links( $post ) {
*
* @param string $type The post_type you want the statuses for. Default 'post'.
* @return string[] An array of all the statuses for the supplied post type.
*
* @phpstan-return list<string>
*/
function get_available_post_statuses( $type = 'post' ) {
$statuses = wp_count_posts( $type );
Expand Down
4 changes: 3 additions & 1 deletion src/wp-includes/class-wp-dependencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ class WP_Dependencies {
*
* @since 2.8.0
*
* @var (int|false)[]
* @var array<string, int|false>
*
* @phpstan-var array<non-empty-string, int|false>
*/
public $groups = array();

Expand Down
17 changes: 17 additions & 0 deletions src/wp-includes/class-wp-http.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@
* Debugging includes several actions, which pass different variables for debugging the HTTP API.
*
* @since 2.7.0
*
* @phpstan-type HTTP_Response array{
* headers: \WpOrg\Requests\Utility\CaseInsensitiveDictionary|array<string, string>,
* body: string,
* response: array{code: int|false, message: string|false},
* cookies: WP_Http_Cookie[],
* filename?: string|null,
* http_response?: WP_HTTP_Requests_Response|null,
* }
*/
#[AllowDynamicProperties]
class WP_Http {
Expand Down Expand Up @@ -166,6 +175,8 @@ class WP_Http {
* @type string|null $filename Optional. Filename of the response.
* @type WP_HTTP_Requests_Response|null $http_response Response object.
* }
*
* @phpstan-return HTTP_Response|WP_Error
*/
public function request( $url, $args = array() ) {
$defaults = array(
Expand Down Expand Up @@ -647,6 +658,8 @@ private function _dispatch_request( $url, $args ) {
* @param string|array $args Optional. Override the defaults.
* @return array|WP_Error Array containing 'headers', 'body', 'response', 'cookies', 'filename'.
* A WP_Error instance upon error. See WP_Http::response() for details.
*
* @phpstan-return HTTP_Response|WP_Error
*/
public function post( $url, $args = array() ) {
$defaults = array( 'method' => 'POST' );
Expand All @@ -665,6 +678,8 @@ public function post( $url, $args = array() ) {
* @param string|array $args Optional. Override the defaults.
* @return array|WP_Error Array containing 'headers', 'body', 'response', 'cookies', 'filename'.
* A WP_Error instance upon error. See WP_Http::response() for details.
*
* @phpstan-return HTTP_Response|WP_Error
*/
public function get( $url, $args = array() ) {
$defaults = array( 'method' => 'GET' );
Expand All @@ -683,6 +698,8 @@ public function get( $url, $args = array() ) {
* @param string|array $args Optional. Override the defaults.
* @return array|WP_Error Array containing 'headers', 'body', 'response', 'cookies', 'filename'.
* A WP_Error instance upon error. See WP_Http::response() for details.
*
* @phpstan-return HTTP_Response|WP_Error
*/
public function head( $url, $args = array() ) {
$defaults = array( 'method' => 'HEAD' );
Expand Down
16 changes: 16 additions & 0 deletions src/wp-includes/class-wp-widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,22 @@ class WP_Widget {
* @param array $args Display arguments including 'before_title', 'after_title',
* 'before_widget', and 'after_widget'.
* @param array $instance The settings for the particular instance of the widget.
*
* @phpstan-param array{
* name?: string,
* id?: string,
* description?: string,
* class?: string,
* before_widget: string,
* after_widget: string,
* before_title: string,
* after_title: string,
* before_sidebar?: string,
* after_sidebar?: string,
* show_in_rest?: bool,
* widget_id?: string,
* widget_name?: string,
* } $args
*/
public function widget( $args, $instance ) {
die( 'function WP_Widget::widget() must be overridden in a subclass.' );
Expand Down
2 changes: 2 additions & 0 deletions src/wp-includes/feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,8 @@ function atom_enclosure() {
*
* @param string $data Input string.
* @return array array(type, value)
*
* @phpstan-return array{'html'|'text'|'xhtml', string}
*/
function prep_atom_text_construct( $data ) {
if ( ! str_contains( $data, '<' ) && ! str_contains( $data, '&' ) ) {
Expand Down
2 changes: 2 additions & 0 deletions src/wp-includes/formatting.php
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,8 @@ function wpautop( $text, $br = true ) {
*
* @param string $input The text which has to be formatted.
* @return string[] Array of the formatted text.
*
* @phpstan-return non-empty-list<string>
*/
function wp_html_split( $input ) {
return preg_split( get_html_split_regex(), $input, -1, PREG_SPLIT_DELIM_CAPTURE );
Expand Down
1 change: 1 addition & 0 deletions src/wp-includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -8379,6 +8379,7 @@ function wp_unique_prefixed_id( $prefix = '' ) {
* @param string $prefix Optional. A prefix to prepend to the generated ID. Default empty string.
* @return string The generated unique ID for the array.
*
* @phpstan-param non-empty-array $data
* @phpstan-return ( $prefix is lowercase-string ? lowercase-string&non-falsy-string : non-falsy-string )
*/
function wp_unique_id_from_values( array $data, string $prefix = '' ): string {
Expand Down
72 changes: 72 additions & 0 deletions src/wp-includes/http.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ function _wp_http_get_object() {
* See WP_Http::request() for information on accepted arguments.
* @return array|WP_Error The response or WP_Error on failure.
* See WP_Http::request() for information on return value.
*
* @phpstan-return array{
* headers: \WpOrg\Requests\Utility\CaseInsensitiveDictionary|array<string, string>,
* body: string,
* response: array{code: int|false, message: string|false},
* cookies: WP_Http_Cookie[],
* filename?: string|null,
* http_response?: WP_HTTP_Requests_Response|null,
* }|WP_Error
*/
function wp_safe_remote_request( $url, $args = array() ) {
$args['reject_unsafe_urls'] = true;
Expand Down Expand Up @@ -77,6 +86,15 @@ function wp_safe_remote_request( $url, $args = array() ) {
* See WP_Http::request() for information on accepted arguments.
* @return array|WP_Error The response or WP_Error on failure.
* See WP_Http::request() for information on return value.
*
* @phpstan-return array{
* headers: \WpOrg\Requests\Utility\CaseInsensitiveDictionary|array<string, string>,
* body: string,
* response: array{code: int|false, message: string|false},
* cookies: WP_Http_Cookie[],
* filename?: string|null,
* http_response?: WP_HTTP_Requests_Response|null,
* }|WP_Error
*/
function wp_safe_remote_get( $url, $args = array() ) {
$args['reject_unsafe_urls'] = true;
Expand Down Expand Up @@ -106,6 +124,15 @@ function wp_safe_remote_get( $url, $args = array() ) {
* See WP_Http::request() for information on accepted arguments.
* @return array|WP_Error The response or WP_Error on failure.
* See WP_Http::request() for information on return value.
*
* @phpstan-return array{
* headers: \WpOrg\Requests\Utility\CaseInsensitiveDictionary|array<string, string>,
* body: string,
* response: array{code: int|false, message: string|false},
* cookies: WP_Http_Cookie[],
* filename?: string|null,
* http_response?: WP_HTTP_Requests_Response|null,
* }|WP_Error
*/
function wp_safe_remote_post( $url, $args = array() ) {
$args['reject_unsafe_urls'] = true;
Expand Down Expand Up @@ -135,6 +162,15 @@ function wp_safe_remote_post( $url, $args = array() ) {
* See WP_Http::request() for information on accepted arguments.
* @return array|WP_Error The response or WP_Error on failure.
* See WP_Http::request() for information on return value.
*
* @phpstan-return array{
* headers: \WpOrg\Requests\Utility\CaseInsensitiveDictionary|array<string, string>,
* body: string,
* response: array{code: int|false, message: string|false},
* cookies: WP_Http_Cookie[],
* filename?: string|null,
* http_response?: WP_HTTP_Requests_Response|null,
* }|WP_Error
*/
function wp_safe_remote_head( $url, $args = array() ) {
$args['reject_unsafe_urls'] = true;
Expand Down Expand Up @@ -162,6 +198,15 @@ function wp_safe_remote_head( $url, $args = array() ) {
* See WP_Http::request() for information on accepted arguments.
* @return array|WP_Error The response array or a WP_Error on failure.
* See WP_Http::request() for information on return value.
*
* @phpstan-return array{
* headers: \WpOrg\Requests\Utility\CaseInsensitiveDictionary|array<string, string>,
* body: string,
* response: array{code: int|false, message: string|false},
* cookies: WP_Http_Cookie[],
* filename?: string|null,
* http_response?: WP_HTTP_Requests_Response|null,
* }|WP_Error
*/
function wp_remote_request( $url, $args = array() ) {
$http = _wp_http_get_object();
Expand All @@ -183,6 +228,15 @@ function wp_remote_request( $url, $args = array() ) {
* See WP_Http::request() for information on accepted arguments.
* @return array|WP_Error The response or WP_Error on failure.
* See WP_Http::request() for information on return value.
*
* @phpstan-return array{
* headers: \WpOrg\Requests\Utility\CaseInsensitiveDictionary|array<string, string>,
* body: string,
* response: array{code: int|false, message: string|false},
* cookies: WP_Http_Cookie[],
* filename?: string|null,
* http_response?: WP_HTTP_Requests_Response|null,
* }|WP_Error
*/
function wp_remote_get( $url, $args = array() ) {
$http = _wp_http_get_object();
Expand All @@ -204,6 +258,15 @@ function wp_remote_get( $url, $args = array() ) {
* See WP_Http::request() for information on accepted arguments.
* @return array|WP_Error The response or WP_Error on failure.
* See WP_Http::request() for information on return value.
*
* @phpstan-return array{
* headers: \WpOrg\Requests\Utility\CaseInsensitiveDictionary|array<string, string>,
* body: string,
* response: array{code: int|false, message: string|false},
* cookies: WP_Http_Cookie[],
* filename?: string|null,
* http_response?: WP_HTTP_Requests_Response|null,
* }|WP_Error
*/
function wp_remote_post( $url, $args = array() ) {
$http = _wp_http_get_object();
Expand All @@ -225,6 +288,15 @@ function wp_remote_post( $url, $args = array() ) {
* See WP_Http::request() for information on accepted arguments.
* @return array|WP_Error The response or WP_Error on failure.
* See WP_Http::request() for information on return value.
*
* @phpstan-return array{
* headers: \WpOrg\Requests\Utility\CaseInsensitiveDictionary|array<string, string>,
* body: string,
* response: array{code: int|false, message: string|false},
* cookies: WP_Http_Cookie[],
* filename?: string|null,
* http_response?: WP_HTTP_Requests_Response|null,
* }|WP_Error
*/
function wp_remote_head( $url, $args = array() ) {
$http = _wp_http_get_object();
Expand Down
2 changes: 1 addition & 1 deletion src/wp-includes/nav-menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function is_nav_menu( $menu ) {
*
* @global array $_wp_registered_nav_menus
*
* @param string[] $locations Associative array of menu location identifiers (like a slug) and descriptive text.
* @param array<string, string> $locations Associative array of menu location identifiers (like a slug) and descriptive text.
*/
function register_nav_menus( $locations = array() ) {
global $_wp_registered_nav_menus;
Expand Down
28 changes: 16 additions & 12 deletions src/wp-includes/robots-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ function wp_robots() {
*
* @see wp_robots_no_robots()
*
* @param array $robots Associative array of robots directives.
* @return array Filtered robots directives.
* @param array<string, bool|string> $robots Associative array of robots directives.
* @return array<string, bool|string> Filtered robots directives.
*/
function wp_robots_noindex( array $robots ) {
if ( ! get_option( 'blog_public' ) ) {
Expand All @@ -86,8 +86,8 @@ function wp_robots_noindex( array $robots ) {
*
* @see wp_robots_no_robots()
*
* @param array $robots Associative array of robots directives.
* @return array Filtered robots directives.
* @param array<string, bool|string> $robots Associative array of robots directives.
* @return array<string, bool|string> Filtered robots directives.
*/
function wp_robots_noindex_embeds( array $robots ) {
if ( is_embed() ) {
Expand All @@ -112,8 +112,8 @@ function wp_robots_noindex_embeds( array $robots ) {
*
* @see wp_robots_no_robots()
*
* @param array $robots Associative array of robots directives.
* @return array Filtered robots directives.
* @param array<string, bool|string> $robots Associative array of robots directives.
* @return array<string, bool|string> Filtered robots directives.
*/
function wp_robots_noindex_search( array $robots ) {
if ( is_search() ) {
Expand All @@ -134,8 +134,10 @@ function wp_robots_noindex_search( array $robots ) {
*
* @since 5.7.0
*
* @param array $robots Associative array of robots directives.
* @return array Filtered robots directives.
* @param array<string, bool|string> $robots Associative array of robots directives.
* @return array<string, bool|string> Filtered robots directives.
Comment thread
westonruter marked this conversation as resolved.
Resolved
*
* @phpstan-return array{ noindex: true, ...<string, bool|string> }
*/
function wp_robots_no_robots( array $robots ) {
$robots['noindex'] = true;
Expand All @@ -161,8 +163,10 @@ function wp_robots_no_robots( array $robots ) {
*
* @since 5.7.0
*
* @param array $robots Associative array of robots directives.
* @return array Filtered robots directives.
* @param array<string, bool|string> $robots Associative array of robots directives.
* @return array<string, bool|string> Filtered robots directives.
*
* @phpstan-return array{ noindex: true, noarchive: true, ...<string, bool|string> }
*/
function wp_robots_sensitive_page( array $robots ) {
$robots['noindex'] = true;
Expand All @@ -182,8 +186,8 @@ function wp_robots_sensitive_page( array $robots ) {
*
* @since 5.7.0
*
* @param array $robots Associative array of robots directives.
* @return array Filtered robots directives.
* @param array<string, bool|string> $robots Associative array of robots directives.
* @return array<string, bool|string> Filtered robots directives.
*/
function wp_robots_max_image_preview_large( array $robots ) {
if ( get_option( 'blog_public' ) ) {
Expand Down
2 changes: 2 additions & 0 deletions src/wp-includes/shortcodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ function has_shortcode( $content, $tag ) {
*
* @param string $content The content to check.
* @return string[] An array of registered shortcode names found in the content.
*
* @phpstan-return list<string>
*/
function get_shortcode_tags_in_content( $content ) {
if ( ! str_contains( $content, '[' ) ) {
Expand Down
Loading
Loading