Skip to content
Open
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
9 changes: 9 additions & 0 deletions src/wp-admin/includes/file.php
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,9 @@ function validate_file_to_edit( $file, $allowed_files = array() ) {
* @type string $url URL of the newly-uploaded file.
* @type string $type Mime type of the newly-uploaded file.
* }
*
* @phpstan-return array{ file: non-empty-string, url: non-empty-string, type: non-empty-string }
* |array{ error: non-empty-string }
*/
function _wp_handle_upload( &$file, $overrides, $time, $action ) {
// The default error handler.
Expand Down Expand Up @@ -1094,6 +1097,9 @@ function wp_handle_upload_error( &$file, $message ) {
* See _wp_handle_upload() for accepted values.
* @param string|null $time Optional. Time formatted in 'yyyy/mm'. Default null.
* @return array See _wp_handle_upload() for return value.
*
* @phpstan-return array{ file: non-empty-string, url: non-empty-string, type: non-empty-string }
* |array{ error: non-empty-string }
*/
function wp_handle_upload( &$file, $overrides = false, $time = null ) {
/*
Expand Down Expand Up @@ -1121,6 +1127,9 @@ function wp_handle_upload( &$file, $overrides = false, $time = null ) {
* See _wp_handle_upload() for accepted values.
* @param string|null $time Optional. Time formatted in 'yyyy/mm'. Default null.
* @return array See _wp_handle_upload() for return value.
*
* @phpstan-return array{ file: non-empty-string, url: non-empty-string, type: non-empty-string }
* |array{ error: non-empty-string }
*/
function wp_handle_sideload( &$file, $overrides = false, $time = null ) {
/*
Expand Down
12 changes: 12 additions & 0 deletions src/wp-includes/post.php
Original file line number Diff line number Diff line change
Expand Up @@ -6888,6 +6888,18 @@ function wp_delete_attachment_files( $post_id, $meta, $backup_sizes, $file ) {
* @type array $image_meta Image metadata.
* @type int $filesize File size of the attachment.
* }
*
* @phpstan-return array{
* width: int<1, max>,
* height: int<1, max>,
* file: non-empty-string,
* sizes: array<non-empty-string, array{
* file: non-empty-string,
* width: int<1, max>,
* height: int<1, max>,
* 'mime-type': non-empty-string,
* }>
* }|false
*/
function wp_get_attachment_metadata( $attachment_id = 0, $unfiltered = false ) {
$attachment_id = (int) $attachment_id;
Expand Down
24 changes: 21 additions & 3 deletions src/wp-includes/rest-api/class-wp-rest-request.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class WP_REST_Request implements ArrayAccess {
* HTTP headers for the request.
*
* @since 4.4.0
* @var array Map of key to value. Key is always lowercase, as per HTTP specification.
* @var array<string, string[]> Map of key to value. Key is always lowercase, as per HTTP specification.
*/
protected $headers = array();

Expand Down Expand Up @@ -155,7 +155,7 @@ public function set_method( $method ) {
*
* @since 4.4.0
*
* @return array Map of key to value. Key is always lowercase, as per HTTP specification.
* @return array<string, string[]> Map of key to value. Key is always lowercase, as per HTTP specification.
*/
public function get_headers() {
return $this->headers;
Expand Down Expand Up @@ -226,7 +226,7 @@ public function get_header( $key ) {
* @since 4.4.0
*
* @param string $key Header name, will be canonicalized to lowercase.
* @return array|null List of string values if set, null otherwise.
* @return string[]|null List of string values if set, null otherwise.
*/
public function get_header_as_array( $key ) {
$key = $this->canonicalize_header_name( $key );
Expand Down Expand Up @@ -588,6 +588,15 @@ public function set_body_params( $params ) {
* @since 4.4.0
*
* @return array Parameter map of key to value.
*
* @phpstan-return array<string, array{
* name: non-empty-string,
* type: non-empty-string,
* size: non-negative-int,
* tmp_name: non-empty-string,
* error: int<0, 8>,
* full_path?: non-empty-string,
* }>
*/
public function get_file_params() {
return $this->params['FILES'];
Expand All @@ -601,6 +610,15 @@ public function get_file_params() {
* @since 4.4.0
*
* @param array $params Parameter map of key to value.
*
* @phpstan-param array<string, array{
* name: non-empty-string,
* type: non-empty-string,
* size: non-negative-int,
* tmp_name: non-empty-string,
* error: int<0, 8>,
* full_path?: non-empty-string,
* }> $params
*/
public function set_file_params( $params ) {
$this->params['FILES'] = $params;
Expand Down
Loading
Loading