-
Notifications
You must be signed in to change notification settings - Fork 107
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
Add strict PHPStan rules for Speculative Loading #1392
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
@@ -19,13 +19,8 @@ | |||
* @since 1.0.0 | |||
*/ | |||
function plsr_print_speculation_rules(): void { | |||
$rules = plsr_get_speculation_rules(); | |||
if ( empty( $rules ) ) { |
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.
This function never returns an empty array, so this condition is dead code.
if ( empty( $args['field'] ) || empty( $args['title'] ) ) { // Invalid. | ||
return; | ||
} |
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.
The field
and title
args are always provided in plsr_add_setting_ui()
.
|
||
if ( ! empty( $args['description'] ) ) { |
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.
The description is always provided in plsr_add_setting_ui()
.
* } | ||
*/ | ||
function plsr_get_stored_setting_value(): array { | ||
return plsr_sanitize_setting( get_option( 'plsr_speculation_rules' ) ); |
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.
The plsr_sanitize_setting()
function could perhaps be eliminated in favor of the JSON schema.
c77c40e
to
7ffe2b1
Compare
This is a follow-up to #1241 to edge closer to full strict rule compliance for PHPStan. See #1219.
See also #775.
This improves typing of functions in the Speculative Loading plugin, and consolidates the obtaining of the stored option value in the
plsr_get_stored_setting_value()
function.