Skip to content

Commit

Permalink
Merge pull request #2221 from WordPress/feature/enqueuedresourceparam…
Browse files Browse the repository at this point in the history
…s-bugfix

WP/EnqueuedResourceParameters: fix handling of an edge case
  • Loading branch information
dingo-d committed Apr 17, 2023
2 parents f3dac10 + 968ff8c commit 39ecc31
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions WordPress/Sniffs/WP/EnqueuedResourceParametersSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ public function process_parameters( $stackPtr, $group_name, $matched_content, $p
$error_ptr = $stackPtr;
if ( false !== $version_param ) {
$error_ptr = $this->phpcsFile->findNext( Tokens::$emptyTokens, $version_param['start'], ( $version_param['end'] + 1 ), true );
if ( false === $error_ptr ) {
$error_ptr = $version_param['start'];
}
}

if ( false === $version_param || 'null' === $version_param['clean'] ) {
Expand Down
3 changes: 3 additions & 0 deletions WordPress/Tests/WP/EnqueuedResourceParametersUnitTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,6 @@ wp_register_script( 'someScript-js', $url, [], 0_0.0_0, true ); // Error - 0, fa

// Safeguard handling of PHP 8.1 explicit octals.
wp_register_script( 'someScript-js', $url, [], 0o0, true ); // Error - 0, false or NULL are not allowed.

// Live coding/parse error.
wp_register_style( src: 'https://example.com/someScript.js', ver: /*to do*/, handle: 'someScript-js', );
1 change: 1 addition & 0 deletions WordPress/Tests/WP/EnqueuedResourceParametersUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public function getErrorList() {
61 => 1,
82 => 1,
85 => 1,
88 => 1,
);
}

Expand Down

0 comments on commit 39ecc31

Please sign in to comment.