diff --git a/functionMap.php b/functionMap.php index e8b0277..3619c69 100644 --- a/functionMap.php +++ b/functionMap.php @@ -415,7 +415,6 @@ 'WP_Widget::update' => [null, 'new_instance' => 'T', 'old_instance' => 'T'], 'WP_Widget::update_callback' => [null, '@final' => '', 'deprecated' => '1'], 'WP_Widget::widget' => [null, 'instance' => 'T', 'args' => '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:boolean,widget_id:string,widget_name:string}'], - 'WP_Widget_Factory::$widgets' => [null, '@phpstan-var' => 'array'], 'WP_Widget_Factory::register' => [null, 'widget' => 'class-string<\WP_Widget>|\WP_Widget'], 'WP_Widget_Factory::unregister' => [null, 'widget' => 'class-string<\WP_Widget>|\WP_Widget'], 'wpdb::get_row' => [null, 'y' => 'int<0, max>'], diff --git a/source/composer.json b/source/composer.json index 57457aa..ee1ec6f 100644 --- a/source/composer.json +++ b/source/composer.json @@ -7,7 +7,7 @@ "ext-mbstring": "*", "ext-openssl": "*", "ext-sodium": "*", - "johnpbloch/wordpress": "7.1" + "johnpbloch/wordpress": "7.1.2" }, "minimum-stability": "stable", "config": { diff --git a/tests/data/return/wp-widget-factory.php b/tests/data/return/wp-widget-factory.php deleted file mode 100644 index 885edab..0000000 --- a/tests/data/return/wp-widget-factory.php +++ /dev/null @@ -1,9 +0,0 @@ -', Faker::wpWidgetFactory()->widgets); diff --git a/wordpress-stubs.php b/wordpress-stubs.php index 65d124d..b08ecb1 100644 --- a/wordpress-stubs.php +++ b/wordpress-stubs.php @@ -43673,8 +43673,8 @@ final class WP_Filter_Sentinel * accepted_args: int, * } * - * @phpstan-implements Iterator> - * @phpstan-implements ArrayAccess> + * @phpstan-implements Iterator> + * @phpstan-implements ArrayAccess> */ #[\AllowDynamicProperties] final class WP_Hook implements \Iterator, \ArrayAccess @@ -43684,7 +43684,7 @@ final class WP_Hook implements \Iterator, \ArrayAccess * * @since 4.7.0 * @var array - * @phpstan-var array> + * @phpstan-var array> */ public $callbacks = array(); /** @@ -43864,7 +43864,7 @@ public function offsetExists($offset) * * @param int $offset The offset to retrieve. * @return array|null If set, the value at the specified offset, null otherwise. - * @phpstan-return array|null + * @phpstan-return array|null */ #[\ReturnTypeWillChange] public function offsetGet($offset) @@ -43879,7 +43879,7 @@ public function offsetGet($offset) * * @param int|null $offset The offset to assign the value to. * @param array $value The value to set. - * @phpstan-param array $value + * @phpstan-param array $value */ #[\ReturnTypeWillChange] public function offsetSet($offset, $value) @@ -43906,7 +43906,7 @@ public function offsetUnset($offset) * @link https://www.php.net/manual/en/iterator.current.php * * @return array|false Array of callbacks at current priority, false if there are no more elements. - * @phpstan-return array|false + * @phpstan-return array|false */ #[\ReturnTypeWillChange] public function current() @@ -43920,7 +43920,7 @@ public function current() * @link https://www.php.net/manual/en/iterator.next.php * * @return array|false Array of callbacks at next priority, false if there are no more elements. - * @phpstan-return array|false + * @phpstan-return array|false */ #[\ReturnTypeWillChange] public function next() @@ -60906,9 +60906,12 @@ class WP_Widget_Factory /** * Widgets array. * + * Keyed by class name for a widget registered by name, and by a prefixed object ID for a widget + * registered as an instance. + * * @since 2.8.0 - * @var array - * @phpstan-var array + * @var array + * @phpstan-var array */ public $widgets = array(); /** @@ -60936,6 +60939,7 @@ public function WP_Widget_Factory() * @since 2.8.0 * @since 4.6.0 Updated the `$widget` parameter to also accept a WP_Widget instance object * instead of simply a `WP_Widget` subclass name. + * @since 7.1.1 The key for an instance is prefixed so that it is never cast to an integer. * * @param string|WP_Widget $widget Either the name of a `WP_Widget` subclass or an instance of a `WP_Widget` subclass. * @phpstan-param class-string<\WP_Widget>|\WP_Widget $widget @@ -60949,6 +60953,7 @@ public function register($widget) * @since 2.8.0 * @since 4.6.0 Updated the `$widget` parameter to also accept a WP_Widget instance object * instead of simply a `WP_Widget` subclass name. + * @since 7.1.1 The key for an instance is prefixed so that it is never cast to an integer. * * @param string|WP_Widget $widget Either the name of a `WP_Widget` subclass or an instance of a `WP_Widget` subclass. * @phpstan-param class-string<\WP_Widget>|\WP_Widget $widget @@ -66780,6 +66785,17 @@ public function render_content() * @since 3.4.0 * * @see WP_Customize_Setting + * + * @phpstan-type Header_Image_Data array{ + * attachment_id?: int, + * url?: string, + * thumbnail_url?: string, + * timestamp?: int, + * width?: int, + * height?: int, + * alt_text?: string, + * attachment_parent?: int, + * } */ final class WP_Customize_Header_Image_Setting extends \WP_Customize_Setting { @@ -66802,6 +66818,35 @@ final class WP_Customize_Header_Image_Setting extends \WP_Customize_Setting public function update($value) { } + /** + * Sanitizes a header value. + * + * The value is expected to be one of the following: + * + * - An array of header image data, with the keys `attachment_id`, `url`, `thumbnail_url`, `timestamp`, `width`, + * `height`, `alt_text`, and `attachment_parent`, as supplied by {@see get_uploaded_header_images()}. Any other + * key is discarded. + * - An array with a `choice` key, being the legacy format in which any of the other accepted values is nested. + * - The string `remove-header`, `random-default-image`, or `random-uploaded-image`. + * - A string corresponding to one of the keys for the array returned by {@see get_uploaded_header_images()}, or + * one of the keys for the array passed into {@see register_default_headers()}. + * + * @since 7.1.1 + * + * @see WP_Customize_Header_Image_Setting::update() + * @see Custom_Image_Header::set_header_image() + * + * @param mixed $value Value to sanitize. + * @return array|string|WP_Error|null Sanitized value, or `null`/`WP_Error` if invalid. The array holds + * the header image data, or that data nested under a `choice` key, + * before the `customize_sanitize_header_image_data` filter, which + * may return anything, is applied to it. + * + * @phpstan-return array|string|WP_Error|null + */ + public function sanitize($value) + { + } } /** * Customize control to represent the auto_add field for a given menu. @@ -90025,6 +90070,7 @@ public function create_item($request) * Checks if a given REST request has access to update a comment. * * @since 4.7.0 + * @since 7.1.1 Target post permissions are checked when a comment's parent post is changed. * * @param WP_REST_Request $request Full details about the request. * @return true|WP_Error True if the request has access to update the item, error object otherwise. @@ -90220,6 +90266,23 @@ public function check_comment_author_email($value, $request, $param) protected function check_is_comment_content_allowed($prepared_comment) { } + /** + * Checks that a post can receive a comment or a note from the current user. + * + * Used when creating a note and when changing the parent post of an existing + * comment or note, so that attaching content to a post is authorized the same + * way whichever path it arrives by. + * + * @since 7.1.1 + * + * @param int $post_id Target post ID. + * @param WP_REST_Request $request Full details about the request. + * @param bool $is_note Optional. Whether the comment is a note. Default false. + * @return true|WP_Error True if the post can receive the comment, error object otherwise. + */ + protected function check_target_post_permission(int $post_id, \WP_REST_Request $request, bool $is_note = \false) + { + } } /** * Controller which provides REST endpoint for exporting current templates @@ -96362,8 +96425,6 @@ public function register_rewrites() * Renders sitemap templates based on rewrite rules. * * @since 5.5.0 - * - * @global WP_Query $wp_query WordPress Query object. * @phpstan-return void */ public function render_sitemaps() @@ -105193,8 +105254,11 @@ function is_plugin_active_for_network($plugin) * Checks for "Site Wide Only: true" for backward compatibility. * * @since 3.0.0 + * @since 7.1.1 The `$plugin` path is normalized with `plugin_basename()` and `trim()`, + * matching how `activate_plugin()` resolves it. * - * @param string $plugin Path to the plugin file relative to the plugins directory. + * @param string $plugin Path to the plugin file. Accepts a path relative to the plugins + * directory, or an absolute path, with or without surrounding whitespace. * @return bool True if plugin is network only, false otherwise. */ function is_network_only_plugin($plugin) @@ -136025,7 +136089,7 @@ function get_search_form($args = array()) * @type string $id Unique ID for the popover element. Default is a * generated unique ID. * @type string $button Existing `button` or `a` markup. Used instead of generated button. - * Default standard button HTML. + * Default empty string. * @type string $label Not used for tooltips. * @type string $close_label Not used for tooltips. * @type string $icon Dashicons icon class for the toggle button. @@ -136061,7 +136125,7 @@ function wp_get_tooltip($content, $args = array()) * @type string $id Unique ID for the popover element. Default is a * generated unique ID. * @type string $button Existing `button` markup. Used instead of generated button. - * Default standard button HTML. + * Default empty string. * @type string $label Accessible label for the toggle button. * Default 'Help', matching the default icon. * Ignored for tooltips. @@ -136102,7 +136166,7 @@ function wp_get_toggletip($content, $args = array()) * @type string $id Unique ID for the popover element. Default is a * generated unique ID. * @type string $button Existing `button` or `a` markup. Used instead of generated button. - * Default standard button HTML. + * Default empty string. * @type string $label Accessible label for the toggle button. * Default 'Help', matching the default icon. * Ignored for tooltips. @@ -151739,6 +151803,7 @@ function _wp_call_all_hook($args) * and no longer returns false, but can still return void for invalid callbacks. * @since 6.9.0 Returns explicit null if an invalid callback is supplied. * @since 7.1.0 Uses spl_object_id() instead of spl_object_hash() for performance. + * @since 7.1.1 The ID for an object callback is prefixed so that it is never cast to an integer array key. * * @access private * @@ -151748,6 +151813,8 @@ function _wp_call_all_hook($args) * @param int $priority Unused. The order in which the functions * associated with a particular action are executed. * @return string|null Unique function ID for usage as array key, or null if it couldn't be determined. + * + * @phpstan-return non-decimal-int-string|null */ function _wp_filter_build_unique_id($hook_name, $callback, $priority): ?string { @@ -162686,6 +162753,21 @@ function get_attachment_template() function wp_set_template_globals() { } + /** + * Determines whether a template found by locate_template() may be loaded. + * + * @since 7.1.2 + * @access private + * + * @global string $wp_stylesheet_path Path to current theme's stylesheet directory. + * @global string $wp_template_path Path to current theme's template directory. + * + * @param string $path Path to an existing template file. + * @return bool Whether the template may be loaded. + */ + function _wp_is_template_path_allowed($path) + { + } /** * Retrieves the name of the highest priority template file that exists. * @@ -162695,6 +162777,7 @@ function wp_set_template_globals() * * @since 2.7.0 * @since 5.5.0 The `$args` parameter was added. + * @since 7.1.2 A template name containing `..` is only located if it resolves inside the theme. * * @global string $wp_stylesheet_path Path to current theme's stylesheet directory. * @global string $wp_template_path Path to current theme's template directory. @@ -163413,6 +163496,7 @@ function get_uploaded_header_images() * Gets the header image data. * * @since 3.4.0 + * @since 7.1.1 The `width` and `height` are cast to non-negative integers. * * @global array $_wp_default_headers *