Skip to content

Commit 72bbd67

Browse files
committed
Fix wrong counting of hook params with nested parenthesis.
1 parent b3c500f commit 72bbd67

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

WPForms/Sniffs/Comments/ParamTagHooksSniff.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,12 @@ private function countArguments( $phpcsFile, $stackPtr ) { // phpcs:ignore Gener
129129

130130
$quantity ++;
131131

132+
if ( ! empty( $tokens[ $currentPosition ]['parenthesis_opener'] ) ) {
133+
$currentPosition = $tokens[ $currentPosition ]['parenthesis_closer'] + 1;
134+
135+
continue;
136+
}
137+
132138
if ( ! empty( $tokens[ $currentPosition ]['bracket_closer'] ) ) {
133139
$currentPosition = $tokens[ $currentPosition ]['bracket_closer'] + 2;
134140

WPForms/Tests/TestFiles/Comments/ParamTagHooks.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,3 +183,15 @@ function () {
183183

184184
// This case generated 'You should have 39 @param tags' (39 as an example).
185185
do_action( 'hook_without_args' );
186+
187+
// This case generated 'You should have 16 @param tags'.
188+
$text = (string) apply_filters(
189+
'wpforms_frontend_shortcode_amp_text',
190+
sprintf( /* translators: %s - URL to a non-amp version of a page with the form. */
191+
__( '<a href="%s">Go to the full page</a> to view and submit the form.', 'wpforms-lite' ),
192+
esc_url( 'some_url' )
193+
),
194+
555,
195+
'http://site.org/cool-page',
196+
[]
197+
);

0 commit comments

Comments
 (0)