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. |
| */ | ||
| function plsr_print_speculation_rules(): void { | ||
| $rules = plsr_get_speculation_rules(); | ||
| if ( empty( $rules ) ) { |
There was a problem hiding this comment.
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.
The field and title args are always provided in plsr_add_setting_ui().
| } | ||
| <?php endforeach; ?> | ||
|
|
||
| if ( ! empty( $args['description'] ) ) { |
There was a problem hiding this comment.
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.
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.