Repository navigation
Code Quality: Resolve the empty.variable PHPStan errors and remove the baseline
#16242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1554,11 +1554,9 @@ protected function parse_search( &$query_vars ) { | |
| $searchand = ' AND '; | ||
| } | ||
|
|
||
| if ( ! empty( $search ) ) { | ||
| $search = " AND ({$search}) "; | ||
| if ( ! is_user_logged_in() ) { | ||
| $search .= " AND ({$wpdb->posts}.post_password = '') "; | ||
| } | ||
| $search = " AND ({$search}) "; | ||
| if ( ! is_user_logged_in() ) { | ||
| $search .= " AND ({$wpdb->posts}.post_password = '') "; | ||
| } | ||
|
|
||
| return $search; | ||
|
|
@@ -2784,9 +2782,7 @@ public function get_posts() { | |
| $status_type_clauses[] = $type_where; | ||
| } | ||
|
|
||
| if ( ! empty( $status_type_clauses ) ) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here too, PHPStan types this variable as |
||
| $where .= ' AND (' . implode( ' OR ', $status_type_clauses ) . ')'; | ||
| } | ||
| $where .= ' AND (' . implode( ' OR ', $status_type_clauses ) . ')'; | ||
| } else { | ||
| $where .= ' AND 1=0 '; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3271,6 +3271,8 @@ function wp_remove_object_terms( $object_id, $terms, $taxonomy ) { | |
| * @param string $slug The string that will be tried for a unique slug. | ||
| * @param object $term The term object that the `$slug` will belong to. | ||
| * @return string Will return a true unique slug. | ||
| * | ||
| * @phpstan-param object{ taxonomy: string, parent?: int, term_id?: int } $term | ||
| */ | ||
| function wp_unique_term_slug( $slug, $term ) { | ||
| global $wpdb; | ||
|
|
@@ -3290,7 +3292,7 @@ function wp_unique_term_slug( $slug, $term ) { | |
| $parent_suffix = ''; | ||
| if ( $needs_suffix && is_taxonomy_hierarchical( $term->taxonomy ) && ! empty( $term->parent ) ) { | ||
| $the_parent = $term->parent; | ||
| while ( ! empty( $the_parent ) ) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And here, the |
||
| do { | ||
| $parent_term = get_term( $the_parent, $term->taxonomy ); | ||
| if ( is_wp_error( $parent_term ) || empty( $parent_term ) ) { | ||
| break; | ||
|
|
@@ -3300,11 +3302,8 @@ function wp_unique_term_slug( $slug, $term ) { | |
| break; | ||
| } | ||
|
|
||
| if ( empty( $parent_term->parent ) ) { | ||
| break; | ||
| } | ||
| $the_parent = $parent_term->parent; | ||
| } | ||
| } while ( ! empty( $the_parent ) ); | ||
| } | ||
|
|
||
| // If we didn't get a unique slug, try appending a number to make it unique. | ||
|
|
||
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I can see that it is never empty, because of this logic above:
wordpress-develop/src/wp-includes/class-wp-query.php
Lines 1469 to 1482 in 71a42df
And PHPStan types
$searchasnon-empty-array<string>.