Skip to content
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

Merged
merged 3 commits into from
Jul 24, 2024

Conversation

westonruter
Copy link
Member

@westonruter westonruter commented Jul 23, 2024

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.

@westonruter westonruter added [Type] Enhancement A suggestion for improvement of an existing feature [Plugin] Speculative Loading Issues for the Speculative Loading plugin (formerly Speculation Rules) skip changelog PRs that should not be mentioned in changelogs labels Jul 23, 2024
@westonruter westonruter added this to the speculation-rules n.e.x.t milestone Jul 23, 2024
@westonruter westonruter requested a review from felixarntz as a code owner July 23, 2024 19:34
Copy link

github-actions bot commented Jul 23, 2024

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: westonruter <[email protected]>
Co-authored-by: swissspidy <[email protected]>

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 ) ) {
Copy link
Member Author

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.

Comment on lines -200 to -202
if ( empty( $args['field'] ) || empty( $args['title'] ) ) { // Invalid.
return;
}
Copy link
Member Author

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'] ) ) {
Copy link
Member Author

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' ) );
Copy link
Member Author

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.

Base automatically changed from update/strict-rules to trunk July 23, 2024 20:25
@westonruter westonruter force-pushed the add/speculation-rules-strict branch from c77c40e to 7ffe2b1 Compare July 23, 2024 20:26
@westonruter westonruter merged commit b319595 into trunk Jul 24, 2024
13 checks passed
@westonruter westonruter deleted the add/speculation-rules-strict branch July 24, 2024 21:57
@felixarntz felixarntz added no milestone PRs that do not have a defined milestone for release and removed skip changelog PRs that should not be mentioned in changelogs labels Nov 15, 2024
@felixarntz felixarntz removed this from the speculation-rules n.e.x.t milestone Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no milestone PRs that do not have a defined milestone for release [Plugin] Speculative Loading Issues for the Speculative Loading plugin (formerly Speculation Rules) [Type] Enhancement A suggestion for improvement of an existing feature
Projects
Status: Done 😃
Development

Successfully merging this pull request may close these issues.

3 participants