Skip to content

Commit

Permalink
Fix a few more static analysis things
Browse files Browse the repository at this point in the history
  • Loading branch information
sirreal committed Nov 29, 2024
1 parent 2d3d5f8 commit 8659898
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/wp-includes/html-api/class-wp-css-selectors.php
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,12 @@ private function whitespace_delimited_list( string $input ): Generator {
*/
public $modifier;

/**
* @param string $name
* @param null|self::MATCH_* $matcher
* @param null|string $value
* @param null|self::MODIFIER_* $modifier
*/
private function __construct( string $name, ?string $matcher = null, ?string $value = null, ?string $modifier = null ) {
$this->name = $name;
$this->matcher = $matcher;
Expand Down Expand Up @@ -1092,19 +1098,20 @@ private static function parse_subclass_selector( string $input, int &$offset ) {
/**
* This corresponds to <complex-selector> in the grammar.
*
* > <complex-selector> = <compound-selector> [ <combinator>? <compound-selector> ]*
* > <complex-selector> = <compound-selector> [ <combinator>? <compound-selector> ] *
*/
final class WP_CSS_Complex_Selector extends WP_CSS_Selector_Parser implements IWP_CSS_Selector_Parser, IWP_CSS_Selector_Matcher {
public function matches( WP_HTML_Processor $processor ): bool {
if ( count( $this->selectors ) === 1 ) {
return $this->selectors[0]->matches( $processor );
}

// First selector must match this location.
if ( ! $this->selectors[0]->matches( $processor ) ) {
return false;
}

if ( count( $this->selectors ) === 1 ) {
return true;
}

/** @var array<string> $breadcrumbs */
$breadcrumbs = array_slice( array_reverse( $processor->get_breadcrumbs() ), 1 );
$selectors = array_slice( $this->selectors, 1 );
return $this->explore_matches( $selectors, $breadcrumbs );
Expand Down

0 comments on commit 8659898

Please sign in to comment.