From 4861af077a6da6fc2a5b3ebc9094357d3d3c4108 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 9 Dec 2022 16:42:22 +0100 Subject: [PATCH] WP/EnqueuedResourceParameters: change `MissingVersion` to a warning Fixes 1472 Includes updated unit tests. --- .../Sniffs/WP/EnqueuedResourceParametersSniff.php | 4 ++-- .../Tests/WP/EnqueuedResourceParametersUnitTest.inc | 8 ++++---- .../Tests/WP/EnqueuedResourceParametersUnitTest.php | 12 +++++------- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/WordPress/Sniffs/WP/EnqueuedResourceParametersSniff.php b/WordPress/Sniffs/WP/EnqueuedResourceParametersSniff.php index 3bed810539..e5b0dd1d3f 100644 --- a/WordPress/Sniffs/WP/EnqueuedResourceParametersSniff.php +++ b/WordPress/Sniffs/WP/EnqueuedResourceParametersSniff.php @@ -134,8 +134,8 @@ public function process_parameters( $stackPtr, $group_name, $matched_content, $p $type = 'style'; } - $this->phpcsFile->addError( - 'Resource version not set in call to %s(). This means new versions of the %s will not always be loaded due to browser caching.', + $this->phpcsFile->addWarning( + 'Resource version not set in call to %s(). This means new versions of the %s may not always be loaded due to browser caching.', $stackPtr, 'MissingVersion', array( $matched_content, $type ) diff --git a/WordPress/Tests/WP/EnqueuedResourceParametersUnitTest.inc b/WordPress/Tests/WP/EnqueuedResourceParametersUnitTest.inc index 6e5cd7e36f..098d40de95 100644 --- a/WordPress/Tests/WP/EnqueuedResourceParametersUnitTest.inc +++ b/WordPress/Tests/WP/EnqueuedResourceParametersUnitTest.inc @@ -1,6 +1,6 @@ 1, 6 => 1, 9 => 1, 10 => 1, - 11 => 1, 12 => 1, 13 => 1, 14 => 1, 22 => 1, - 39 => 1, - 42 => 1, - 45 => 1, 54 => 1, 57 => 1, ); @@ -51,9 +46,12 @@ public function getErrorList() { */ public function getWarningList() { return array( - 3 => 1, + 3 => 2, + 11 => 1, 32 => 1, - 39 => 1, + 39 => 2, + 42 => 1, + 45 => 1, ); }