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
20 changes: 20 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,23 @@ parameters:
message: '#^PHPDoc tag @throws with type InvalidArgumentException\|ValueError is not subtype of Throwable$#'
path: src/wp-includes/compat.php
reportUnmatched: false

# Level 5:
# substr_compare()'s $length has always accepted null, meaning "compare the full length". PHP 7.4 spelled
# that `int $length = null`, where the null default makes the parameter implicitly nullable, and PHP 8.0
# only made it explicit as `?int $length = null`. The behavior never differed: verified on PHP 7.4 that
# passing null compares the whole string rather than coercing to a length of 0.
#
# PHPStan reads the two spellings from two sources and only one is right. Its PHP 8 stub carries `?int`,
# but the pre-8.0 `resources/functionMap.php` records the type as plain `int`, having dropped the implicit
# nullability when it was transcribed from the old manual. Because `phpVersion.min` is 70400, the legacy
# map wins and null is reported as invalid.
#
# This lives here rather than in a baseline because a baseline entry records work still to be done, and
# there is none: the call is correct on every version WordPress supports, and the fault is in PHPStan's
# data. Passing an explicit length purely to satisfy it would change working code to suit a tooling bug.
# `reportUnmatched: false` so this entry lapses quietly if PHPStan corrects the map.
-
message: '#^Parameter \#4 \$length of function substr_compare expects int, null given\.$#'
path: src/wp-includes/html-api/class-wp-html-tag-processor.php
reportUnmatched: false
2 changes: 1 addition & 1 deletion src/wp-admin/includes/class-wp-posts-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -1135,7 +1135,7 @@ protected function _column_title( $post, $classes, $data, $primary ) {
* @return string The post title, or 'no title' if no title.
*/
protected function get_primary_column_aria_label( $item ) {
return isset( $item->post_title ) && ! empty( $item->post_title ) ? $item->post_title : __( 'no title' );
return ! empty( $item->post_title ) ? $item->post_title : __( 'no title' );
}

/**
Expand Down
5 changes: 5 additions & 0 deletions src/wp-admin/users.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,11 @@

<ul>
<?php
/**
* @global wpdb $wpdb WordPress database abstraction object.
*/
global $wpdb;

$go_delete = 0;
$users_have_content = false;

Expand Down
2 changes: 1 addition & 1 deletion src/wp-includes/block-supports/states.php
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ function wp_add_block_state_style_rule( &$css_rules, $state, $selector, $style,
*/
function wp_get_block_state_style_rules( $state_styles, $block_type, $rules_group = null ) {
$css_rules = array();
$block_selectors = isset( $block_type->selectors ) && is_array( $block_type->selectors )
$block_selectors = is_array( $block_type->selectors )
? $block_type->selectors
: array();

Expand Down
5 changes: 3 additions & 2 deletions src/wp-includes/class-wp-block-type.php
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,9 @@ public function __construct( $block_type, $args = array() ) {
*
* @param string $name Deprecated property name.
*
* @return string|string[]|null The value read from the new property if the first item in the array provided,
* null when value not found or when unknown property name provided.
* @return string|string[]|array[]|null The value read from the new property if the first item in the array
* provided, the variations or uses context arrays for those two names,
* null when value not found or when unknown property name provided.
*/
public function __get( $name ) {
if ( 'variations' === $name ) {
Expand Down
14 changes: 8 additions & 6 deletions src/wp-includes/class-wp-comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,24 @@ final class WP_Comment {
/**
* Comment ID.
*
* A numeric string, for compatibility reasons.
* A numeric string, for compatibility reasons. Note that {@see get_comment_to_edit()}
* replaces it with an integer in place.
*
* @since 4.4.0
* @var string
* @phpstan-var numeric-string
* @var string|int
* @phpstan-var numeric-string|int
*/
public $comment_ID;

/**
* ID of the post the comment is associated with.
*
* A numeric string, for compatibility reasons.
* A numeric string, for compatibility reasons. Note that {@see get_comment_to_edit()}
* replaces it with an integer in place.
*
* @since 4.4.0
* @var string
* @phpstan-var numeric-string
* @var string|int
* @phpstan-var numeric-string|int
*/
public $comment_post_ID = '0';

Expand Down
37 changes: 19 additions & 18 deletions src/wp-includes/class-wp-theme-json.php
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ class WP_Theme_JSON {
* @return array Responsive media queries.
*/
public static function get_viewport_media_queries( $viewport_settings = null, $options = array() ) {
$breakpoints = static::sanitize_viewport_settings( $viewport_settings );
$breakpoints = self::sanitize_viewport_settings( $viewport_settings );

$responsive_media_queries = array();

Expand Down Expand Up @@ -788,7 +788,7 @@ private static function is_valid_viewport_breakpoint_size( $value ) {
* @return float|null Viewport breakpoint size in pixels, or null when invalid.
*/
private static function get_viewport_breakpoint_value_in_pixels( $value ) {
if ( ! static::is_valid_viewport_breakpoint_size( $value ) ) {
if ( ! self::is_valid_viewport_breakpoint_size( $value ) ) {
return null;
}

Expand Down Expand Up @@ -831,7 +831,7 @@ private static function sanitize_viewport_settings( $viewport_settings ) {
$breakpoints = array();
foreach ( array_keys( static::DEFAULT_VIEWPORT_BREAKPOINTS ) as $breakpoint ) {
$value = $viewport_settings[ $breakpoint ] ?? null;
$px = static::get_viewport_breakpoint_value_in_pixels( $value );
$px = self::get_viewport_breakpoint_value_in_pixels( $value );
if ( null !== $px ) {
$breakpoints[ $breakpoint ] = array(
'value' => trim( $value ),
Expand Down Expand Up @@ -989,8 +989,8 @@ private function process_pseudo_selectors( $node, $base_selector, $settings, $bl

if ( is_array( $block_metadata ) ) {
$feature_declarations = $this->get_feature_declarations_for_node( $block_metadata, $pseudo_node );
$feature_declarations = static::update_paragraph_text_indent_selector( $feature_declarations, $settings, $block_name );
$feature_declarations = static::update_button_width_declarations( $feature_declarations, $settings );
$feature_declarations = self::update_paragraph_text_indent_selector( $feature_declarations, $settings, $block_name );
$feature_declarations = self::update_button_width_declarations( $feature_declarations, $settings );

foreach ( $feature_declarations as $feature_selector => $declarations ) {
$target_selector = is_array( $style_variation )
Expand Down Expand Up @@ -1457,7 +1457,7 @@ protected static function sanitize( $input, $valid_block_names, $valid_element_n
$result = static::remove_keys_not_in_schema( $input[ $subtree ], $schema[ $subtree ] );

if ( 'settings' === $subtree && array_key_exists( 'viewport', $input[ $subtree ] ) ) {
$result['viewport'] = static::sanitize_viewport_settings( $input[ $subtree ]['viewport'] );
$result['viewport'] = self::sanitize_viewport_settings( $input[ $subtree ]['viewport'] );
}

if ( empty( $result ) ) {
Expand Down Expand Up @@ -2509,7 +2509,7 @@ protected function get_css_variables( $nodes, $origins ) {
continue;
}

$target = static::get_feature_selector( $feature_selectors, $preset_metadata['path'][0], $selector );
$target = self::get_feature_selector( $feature_selectors, $preset_metadata['path'][0], $selector );

if ( ! isset( $vars_by_selector[ $target ] ) ) {
$vars_by_selector[ $target ] = array();
Expand Down Expand Up @@ -3824,11 +3824,11 @@ public function get_styles_for_block( $block_metadata ) {

// Update text indent selector for paragraph blocks based on the textIndent setting.
$block_name = $block_metadata['name'] ?? null;
$feature_declarations = static::update_paragraph_text_indent_selector( $feature_declarations, $settings, $block_name );
$feature_declarations = self::update_paragraph_text_indent_selector( $feature_declarations, $settings, $block_name );
$block_elements = $block_metadata['elements'] ?? array();

// Update button width declarations for percentage values to use calc() with block gap.
$feature_declarations = static::update_button_width_declarations( $feature_declarations, $settings );
$feature_declarations = self::update_button_width_declarations( $feature_declarations, $settings );

// If there are style variations, generate the declarations for them, including any feature selectors the block may have.
$style_variation_declarations = array();
Expand All @@ -3844,10 +3844,10 @@ public function get_styles_for_block( $block_metadata ) {
$variation_declarations = static::get_feature_declarations_for_node( $block_metadata, $style_variation_node );

// Update text indent selector for paragraph blocks based on the textIndent setting.
$variation_declarations = static::update_paragraph_text_indent_selector( $variation_declarations, $settings, $block_name );
$variation_declarations = self::update_paragraph_text_indent_selector( $variation_declarations, $settings, $block_name );

// Update button width declarations for percentage values to use calc() with block gap.
$variation_declarations = static::update_button_width_declarations( $variation_declarations, $settings );
$variation_declarations = self::update_button_width_declarations( $variation_declarations, $settings );

// Combine selectors with style variation's selector and add to overall style variation declarations.
foreach ( $variation_declarations as $current_selector => $new_declarations ) {
Expand All @@ -3864,7 +3864,7 @@ public function get_styles_for_block( $block_metadata ) {
if ( isset( $block_metadata['name'] ) ) {
$block_name = $block_metadata['name'];
} elseif ( in_array( 'blocks', $block_metadata['path'], true ) && count( $block_metadata['path'] ) >= 3 ) {
$block_name = static::get_block_name_from_metadata_path( $block_metadata );
$block_name = self::get_block_name_from_metadata_path( $block_metadata );
} else {
$block_name = null;
}
Expand Down Expand Up @@ -3902,8 +3902,8 @@ public function get_styles_for_block( $block_metadata ) {
$breakpoint_media = $responsive_media_queries[ $breakpoint ];
// Process feature-level declarations for this breakpoint.
$breakpoint_feature_declarations = static::get_feature_declarations_for_node( $block_metadata, $breakpoint_node );
$breakpoint_feature_declarations = static::update_paragraph_text_indent_selector( $breakpoint_feature_declarations, $settings, $block_name );
$breakpoint_feature_declarations = static::update_button_width_declarations( $breakpoint_feature_declarations, $settings );
$breakpoint_feature_declarations = self::update_paragraph_text_indent_selector( $breakpoint_feature_declarations, $settings, $block_name );
$breakpoint_feature_declarations = self::update_button_width_declarations( $breakpoint_feature_declarations, $settings );
foreach ( $breakpoint_feature_declarations as $feature_selector => $feature_decl ) {
$combined_selectors = static::get_block_style_variation_feature_selector( $style_variation, $feature_selector );

Expand Down Expand Up @@ -4681,7 +4681,7 @@ public static function remove_insecure_properties( $theme_json, $origin = 'theme
}

$block_name = in_array( 'blocks', $metadata['path'], true )
? static::get_block_name_from_metadata_path( $metadata )
? self::get_block_name_from_metadata_path( $metadata )
: null;

// The global styles custom CSS is not sanitized, but can only be edited by users with 'edit_css' capability.
Expand Down Expand Up @@ -5014,7 +5014,7 @@ protected static function remove_insecure_settings( $input, $is_root = false ) {
self::preserve_valid_typed_settings( $input, $output, static::VALID_SETTINGS );

if ( $is_root && array_key_exists( 'viewport', $input ) ) {
$output['viewport'] = static::sanitize_viewport_settings( $input['viewport'] );
$output['viewport'] = self::sanitize_viewport_settings( $input['viewport'] );
}

return $output;
Expand Down Expand Up @@ -5672,8 +5672,9 @@ protected static function get_block_element_selectors( $root_selector ) {
*
* @since 6.3.0
*
* @param object $metadata The related block metadata containing selectors.
* @param object $node A merged theme.json node for block or variation.
* @param array $metadata The related block metadata containing selectors.
* @param array $node A merged theme.json node for block or variation. Features
* promoted to their own selector are removed from it.
* @return array The style declarations for the node's features with custom
* selectors.
*/
Expand Down
2 changes: 2 additions & 0 deletions src/wp-includes/class-wp-user.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
* @property string $display_name
* @property string $spam
* @property string $deleted
* @property string $comment_shortcuts
* @property string $infinite_scrolling
* @property string $locale
* @property string $rich_editing
* @property string $syntax_highlighting
Expand Down
2 changes: 1 addition & 1 deletion src/wp-includes/class-wp-view-config-data.php
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ private function merge_properties( $current, $incoming, $replace_lists ) {
// A non-empty list only lands where a list (or nothing) lives, under
// merge() and replace() alike. An empty array is shape-ambiguous and
// exempt, so replace() with an empty list can still clear a list.
if ( array() !== $incoming && is_array( $current ) && ! array_is_list( $current ) && array() !== $current ) {
if ( array() !== $incoming && is_array( $current ) && ! array_is_list( $current ) ) {
_doing_it_wrong(
__METHOD__,
esc_html__( 'A view configuration patch value must match the shape of the value it patches: a list merges into a list, and an associative array into an associative array.' ),
Expand Down
3 changes: 2 additions & 1 deletion src/wp-includes/class-wp-widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ public function update( $new_instance, $old_instance ) {
* @since 2.8.0
*
* @param array $instance The settings for the particular instance of the widget.
* @return string|null Default return is 'noform'. A subclass may opt to return null.
* @return string|void Default return is 'noform'. A subclass which echoes its own
* form returns nothing.
*/
public function form( $instance ) {
echo '<p class="no-options-widget">' . __( 'There are no options for this widget.' ) . '</p>';
Expand Down
2 changes: 1 addition & 1 deletion src/wp-includes/taxonomy.php
Original file line number Diff line number Diff line change
Expand Up @@ -1592,7 +1592,7 @@ function unregister_term_meta( $taxonomy, $meta_key ) {
* @phpstan-return (
* $term is null ? null : (
* $term is 0 ? 0 : (
* $taxonomy is '' ? int|null : (
* $taxonomy is '' ? numeric-string|null : (
* array{
* term_id: numeric-string,
* term_taxonomy_id: numeric-string,
Expand Down
Loading
Loading