Skip to content
Draft
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: 5 additions & 4 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,11 @@ parameters:
path: src/wp-includes/html-api/class-wp-html-processor.php
-
# The early return at the start of step() narrows $last_error to null, and PHPStan does not see that
# bookmark_token() sets it to ERROR_EXCEEDED_MAX_BOOKMARKS before throwing, whether it is called directly
# in step() or via insert_virtual_node() in a step_*() method. So it reports that the checks in both catch
# blocks of step() can never match, when in fact they do whenever bookmarks run out.
# bookmark_token() sets it to ERROR_EXCEEDED_MAX_BOOKMARKS before throwing. A catch block sees the scope
# from where the exception was thrown, which is before the call's side effects apply, so marking
# bookmark_token() as `@phpstan-impure` does not help. So PHPStan reports that the check in the catch
# block after the direct call in step() can never match, when in fact it does whenever bookmarks run out.
message: '#^Strict comparison using \=\=\= between ''exceeded\-max…'' and null will always evaluate to false\.$#'
identifier: identical.alwaysFalse
count: 2
count: 1
path: src/wp-includes/html-api/class-wp-html-processor.php
4 changes: 4 additions & 0 deletions src/wp-admin/includes/class-automatic-upgrader-skin.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class Automatic_Upgrader_Skin extends WP_Upgrader_Skin {
* for being writable. Default empty.
* @param bool $allow_relaxed_file_ownership Optional. Whether to allow Group/World writable. Default false.
* @return bool True on success, false on failure.
*
* @phpstan-impure
*/
public function request_filesystem_credentials( $error = false, $context = '', $allow_relaxed_file_ownership = false ) {
if ( $context ) {
Expand Down Expand Up @@ -70,6 +72,8 @@ public function get_upgrade_messages() {
*
* @param string|array|WP_Error $feedback Message data.
* @param mixed ...$args Optional text replacements.
*
* @phpstan-impure
*/
public function feedback( $feedback, ...$args ) {
if ( is_wp_error( $feedback ) ) {
Expand Down
2 changes: 2 additions & 0 deletions src/wp-admin/includes/class-bulk-plugin-upgrader-skin.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class Bulk_Plugin_Upgrader_Skin extends Bulk_Upgrader_Skin {
* Sets up the strings used in the update process.
*
* @since 3.0.0
*
* @phpstan-impure
*/
public function add_strings() {
parent::add_strings();
Expand Down
2 changes: 2 additions & 0 deletions src/wp-admin/includes/class-bulk-theme-upgrader-skin.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ class Bulk_Theme_Upgrader_Skin extends Bulk_Upgrader_Skin {
* Sets up the strings used in the update process.
*
* @since 3.0.0
*
* @phpstan-impure
*/
public function add_strings() {
parent::add_strings();
Expand Down
8 changes: 8 additions & 0 deletions src/wp-admin/includes/class-bulk-upgrader-skin.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public function __construct( $args = array() ) {
* Sets up the strings used in the update process.
*
* @since 3.0.0
*
* @phpstan-impure
*/
public function add_strings() {
$this->upgrader->strings['skin_upgrade_start'] = __( 'The update process is starting. This process may take a while on some hosts, so please be patient.' );
Expand Down Expand Up @@ -124,6 +126,8 @@ public function footer() {
* @since 5.9.0 Renamed `$error` to `$errors` for PHP 8 named parameter support.
*
* @param string|WP_Error $errors Errors.
*
* @phpstan-impure
*/
public function error( $errors ) {
if ( is_string( $errors ) && isset( $this->upgrader->strings[ $errors ] ) ) {
Expand Down Expand Up @@ -179,6 +183,8 @@ public function bulk_footer() {
* @since 3.0.0
*
* @param string $title
*
* @phpstan-impure
*/
public function before( $title = '' ) {
$this->in_loop = true;
Expand Down Expand Up @@ -265,6 +271,8 @@ public function after( $title = '' ) {
* Resets the properties used in the update process.
*
* @since 3.0.0
*
* @phpstan-impure
*/
public function reset() {
$this->in_loop = false;
Expand Down
2 changes: 2 additions & 0 deletions src/wp-admin/includes/class-core-upgrader.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class Core_Upgrader extends WP_Upgrader {
* Initializes the upgrade strings.
*
* @since 2.8.0
*
* @phpstan-impure
*/
public function upgrade_strings() {
$this->strings['up_to_date'] = __( 'WordPress is at the latest version.' );
Expand Down
4 changes: 4 additions & 0 deletions src/wp-admin/includes/class-custom-background.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ public function admin_load() {
* Executes custom background modification.
*
* @since 3.0.0
*
* @phpstan-impure
*/
public function take_action() {
if ( empty( $_POST ) ) {
Expand Down Expand Up @@ -515,6 +517,8 @@ public function admin_page() {
* Handles an Image upload for the background image.
*
* @since 3.0.0
*
* @phpstan-impure
*/
public function handle_upload() {
if ( empty( $_FILES ) ) {
Expand Down
6 changes: 6 additions & 0 deletions src/wp-admin/includes/class-custom-image-header.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ public function css_includes() {
* Executes custom header modification.
*
* @since 2.6.0
*
* @phpstan-impure
*/
public function take_action() {
if ( ! current_user_can( 'edit_theme_options' ) ) {
Expand Down Expand Up @@ -277,6 +279,8 @@ public function take_action() {
* @since 3.0.0
*
* @global array $_wp_default_headers Default headers registered for themes.
*
* @phpstan-impure
*/
public function process_default_headers() {
global $_wp_default_headers;
Expand Down Expand Up @@ -1114,6 +1118,8 @@ public function step_3() {
* Displays last step of custom header image page.
*
* @since 2.1.0
*
* @phpstan-impure
*/
public function finished() {
$this->updated = true;
Expand Down
4 changes: 4 additions & 0 deletions src/wp-admin/includes/class-language-pack-upgrader.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ public static function async_upgrade( $upgrader = false ) {
* Initializes the upgrade strings.
*
* @since 3.7.0
*
* @phpstan-impure
*/
public function upgrade_strings() {
$this->strings['starting_upgrade'] = __( 'Some of your translations need updating. Sit tight for a few more seconds while they are updated as well.' );
Expand Down Expand Up @@ -173,6 +175,8 @@ public function upgrade( $update = false, $args = array() ) {
* }
* @return array|bool|WP_Error Will return an array of results, or true if there are no updates,
* false or WP_Error for initial errors.
*
* @phpstan-impure
*/
public function bulk_upgrade( $language_updates = array(), $args = array() ) {
global $wp_filesystem;
Expand Down
4 changes: 4 additions & 0 deletions src/wp-admin/includes/class-plugin-installer-skin.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ public function __construct( $args = array() ) {
* Performs an action before installing a plugin.
*
* @since 2.8.0
*
* @phpstan-impure
*/
public function before() {
if ( ! empty( $this->api ) ) {
Expand Down Expand Up @@ -196,6 +198,8 @@ public function after() {
* @since 5.5.0
*
* @return bool Whether the plugin can be overwritten and HTML was outputted.
*
* @phpstan-impure
*/
private function do_overwrite() {
if ( 'upload' !== $this->type || ! is_wp_error( $this->result ) || 'folder_exists' !== $this->result->get_error_code() ) {
Expand Down
2 changes: 2 additions & 0 deletions src/wp-admin/includes/class-plugin-upgrader-skin.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ public function __construct( $args = array() ) {
* Performs an action following a single plugin update.
*
* @since 2.8.0
*
* @phpstan-impure
*/
public function after() {
$this->plugin = $this->upgrader->plugin_info();
Expand Down
8 changes: 8 additions & 0 deletions src/wp-admin/includes/class-plugin-upgrader.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ class Plugin_Upgrader extends WP_Upgrader {
* Initializes the upgrade strings.
*
* @since 2.8.0
*
* @phpstan-impure
*/
public function upgrade_strings() {
$this->strings['up_to_date'] = __( 'The plugin is at the latest version.' );
Expand All @@ -71,6 +73,8 @@ public function upgrade_strings() {
* Initializes the installation strings.
*
* @since 2.8.0
*
* @phpstan-impure
*/
public function install_strings() {
$this->strings['no_package'] = __( 'Installation package not available.' );
Expand Down Expand Up @@ -286,6 +290,8 @@ public function upgrade( $plugin, $args = array() ) {
* @type bool $clear_update_cache Whether to clear the plugin updates cache if successful. Default true.
* }
* @return array|false An array of results indexed by plugin file, or false if unable to connect to the filesystem.
*
* @phpstan-impure
*/
public function bulk_upgrade( $plugins, $args = array() ) {
$wp_version = wp_get_wp_version();
Expand Down Expand Up @@ -463,6 +469,8 @@ public function bulk_upgrade( $plugins, $args = array() ) {
*
* @param string $source The path to the downloaded package source.
* @return string|WP_Error The source as passed, or a WP_Error object on failure.
*
* @phpstan-impure
*/
public function check_package( $source ) {
global $wp_filesystem;
Expand Down
4 changes: 4 additions & 0 deletions src/wp-admin/includes/class-theme-installer-skin.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ public function __construct( $args = array() ) {
* Performs an action before installing a theme.
*
* @since 2.8.0
*
* @phpstan-impure
*/
public function before() {
if ( ! empty( $this->api ) ) {
Expand Down Expand Up @@ -217,6 +219,8 @@ public function after() {
* @since 5.5.0
*
* @return bool Whether the theme can be overwritten and HTML was outputted.
*
* @phpstan-impure
*/
private function do_overwrite() {
if ( 'upload' !== $this->type || ! is_wp_error( $this->result ) || 'folder_exists' !== $this->result->get_error_code() ) {
Expand Down
10 changes: 10 additions & 0 deletions src/wp-admin/includes/class-theme-upgrader.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ class Theme_Upgrader extends WP_Upgrader {
* Initializes the upgrade strings.
*
* @since 2.8.0
*
* @phpstan-impure
*/
public function upgrade_strings() {
$this->strings['up_to_date'] = __( 'The theme is at the latest version.' );
Expand All @@ -69,6 +71,8 @@ public function upgrade_strings() {
* Initializes the installation strings.
*
* @since 2.8.0
*
* @phpstan-impure
*/
public function install_strings() {
$this->strings['no_package'] = __( 'Installation package not available.' );
Expand Down Expand Up @@ -123,6 +127,8 @@ public function install_strings() {
* @return bool
*
* @phpstan-param non-empty-array<string, mixed> $child_result
*
* @phpstan-impure
*/
public function check_parent_theme_filter( $install_result, $hook_extra, $child_result ) {
// Check to see if we need to install a parent theme.
Expand Down Expand Up @@ -386,6 +392,8 @@ public function upgrade( $theme, $args = array() ) {
* Default true.
* }
* @return array[]|false An array of results, or false if unable to connect to the filesystem.
*
* @phpstan-impure
*/
public function bulk_upgrade( $themes, $args = array() ) {
$wp_version = wp_get_wp_version();
Expand Down Expand Up @@ -565,6 +573,8 @@ public function bulk_upgrade( $themes, $args = array() ) {
*
* @param string $source The path to the downloaded package source.
* @return string|WP_Error The source as passed, or a WP_Error object on failure.
*
* @phpstan-impure
*/
public function check_package( $source ) {
global $wp_filesystem;
Expand Down
2 changes: 2 additions & 0 deletions src/wp-admin/includes/class-walker-nav-menu-checklist.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ public function end_lvl( &$output, $depth = 0, $args = null ) {
* @param int $depth Depth of menu item. Used for padding.
* @param stdClass $args Not used.
* @param int $current_object_id Optional. ID of the current menu item. Default 0.
*
* @phpstan-impure
*/
public function start_el( &$output, $data_object, $depth = 0, $args = null, $current_object_id = 0 ) {
global $_nav_menu_placeholder, $nav_menu_selected_id;
Expand Down
2 changes: 2 additions & 0 deletions src/wp-admin/includes/class-walker-nav-menu-edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public function end_lvl( &$output, $depth = 0, $args = null ) {}
* @param int $depth Depth of menu item. Used for padding.
* @param stdClass $args Not used.
* @param int $current_object_id Optional. ID of the current menu item. Default 0.
*
* @phpstan-impure
*/
public function start_el( &$output, $data_object, $depth = 0, $args = null, $current_object_id = 0 ) {
global $_wp_nav_menu_max_depth;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public function get_columns() {
* @since 5.6.0
*
* @global int $user_id User ID.
*
* @phpstan-impure
*/
public function prepare_items() {
global $user_id;
Expand Down
4 changes: 4 additions & 0 deletions src/wp-admin/includes/class-wp-automatic-updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,8 @@ protected function send_core_update_notification_email( $item ) {
* $type is 'translation' ? array<mixed>|bool|WP_Error|null : bool|WP_Error|null
* )
* )
*
* @phpstan-impure
*/
public function update( $type, $item ) {
$skin = new Automatic_Upgrader_Skin();
Expand Down Expand Up @@ -1905,6 +1907,8 @@ protected function send_debug_email() {
* @global int $upgrading The Unix timestamp marking when upgrading WordPress began.
*
* @return bool Whether a fatal error was detected.
*
* @phpstan-impure
*/
protected function has_fatal_error() {
global $upgrading;
Expand Down
8 changes: 8 additions & 0 deletions src/wp-admin/includes/class-wp-comments-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ public function ajax_user_can() {
* @global string $comment_status Comment status filter.
* @global string $comment_type Comment type filter.
* @global string $search Search term.
*
* @phpstan-impure
*/
public function prepare_items() {
global $mode, $post_id, $comment_status, $comment_type, $search;
Expand Down Expand Up @@ -598,6 +600,8 @@ protected function get_default_primary_column_name() {
* Overrides the parent display() method to render extra comments.
*
* @since 3.1.0
*
* @phpstan-impure
*/
public function display() {
wp_nonce_field( 'fetch-list-' . get_class( $this ), '_ajax_fetch_list_nonce' );
Expand Down Expand Up @@ -668,6 +672,8 @@ public function display() {
* @global WP_Comment $comment Global comment object.
*
* @param WP_Comment $item The comment object.
*
* @phpstan-impure
*/
public function single_row( $item ) {
global $post, $comment;
Expand Down Expand Up @@ -1105,6 +1111,8 @@ public function column_date( $comment ) {
* Outputs the response column.
*
* @param WP_Comment $comment The comment object.
*
* @phpstan-impure
*/
public function column_response( $comment ) {
$post = get_post();
Expand Down
6 changes: 6 additions & 0 deletions src/wp-admin/includes/class-wp-filesystem-base.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ public function wp_lang_dir() {
* @param string $base Optional. The folder to start searching from. Default '.'.
* @param bool $verbose Optional. True to display debug information. Default false.
* @return string|false The location of the remote path, or false on failure.
*
* @phpstan-impure
*/
public function find_base_dir( $base = '.', $verbose = false ) {
_deprecated_function( __FUNCTION__, '2.7.0', 'WP_Filesystem_Base::abspath() or WP_Filesystem_Base::wp_*_dir()' );
Expand All @@ -174,6 +176,8 @@ public function find_base_dir( $base = '.', $verbose = false ) {
* @param string $base Optional. The folder to start searching from. Default '.'.
* @param bool $verbose Optional. True to display debug information. Default false.
* @return string|false The location of the remote path, or false on failure.
*
* @phpstan-impure
*/
public function get_base_dir( $base = '.', $verbose = false ) {
_deprecated_function( __FUNCTION__, '2.7.0', 'WP_Filesystem_Base::abspath() or WP_Filesystem_Base::wp_*_dir()' );
Expand All @@ -191,6 +195,8 @@ public function get_base_dir( $base = '.', $verbose = false ) {
*
* @param string $folder the folder to locate.
* @return string|false The location of the remote path, false on failure.
*
* @phpstan-impure
*/
public function find_folder( $folder ) {
if ( isset( $this->cache[ $folder ] ) ) {
Expand Down
Loading
Loading