Skip to content

Commit 365002e

Browse files
committed
Improve skipping parenthesis in arguments.
1 parent 56a6c5d commit 365002e

File tree

3 files changed

+46
-14
lines changed

3 files changed

+46
-14
lines changed

WPForms/Sniffs/Comments/ParamTagHooksSniff.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ private function countArguments( $phpcsFile, $stackPtr ) { // phpcs:ignore Gener
126126
continue;
127127
}
128128

129-
if ( in_array( $tokens[ $currentPosition ]['code'], [ T_ARRAY, T_OPEN_SHORT_ARRAY ], true ) ) {
129+
if ( in_array( $tokens[ $currentPosition ]['code'], [ T_ARRAY, T_OPEN_SHORT_ARRAY, T_CLOSURE ], true ) ) {
130130
$quantity ++;
131131
}
132132

@@ -136,7 +136,7 @@ private function countArguments( $phpcsFile, $stackPtr ) { // phpcs:ignore Gener
136136

137137
$quantity ++;
138138

139-
$currentPosition = $phpcsFile->findNext( T_COMMA, $currentPosition + 1 );
139+
$currentPosition = $phpcsFile->findNext( [ T_COMMA, T_ARRAY, T_OPEN_SHORT_ARRAY, T_OPEN_PARENTHESIS, T_OPEN_SQUARE_BRACKET, T_OPEN_CURLY_BRACKET ], $currentPosition + 1 );
140140

141141
if ( ! $currentPosition ) {
142142
break;

WPForms/Tests/TestFiles/Comments/ParamTagHooks.php

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,26 +66,34 @@
6666
*
6767
* @since 1.3.0
6868
*
69-
* @param object $response Response data.
70-
* @param array $request_args Request arguments.
71-
* @param array $contact GetResponse contact data.
72-
* @param array $connection Connection data.
73-
* @param array $args Additional arguments.
69+
* @param object $response Response data.
70+
* @param array $request_args Request arguments.
71+
* @param array $contact GetResponse contact data.
72+
* @param array $connection Connection data.
73+
* @param array $args Additional arguments.
74+
* @param mixed $arg6 Test argument.
75+
* @param mixed $arg7 Test argument.
76+
* @param mixed $arg8 Test argument.
77+
* @param mixed $arg9 Test argument.
78+
* @param mixed $arg10 Test argument.
79+
* @param mixed $arg11 Test argument.
80+
* @param mixed $arg12 Test argument.
81+
* @param mixed $arg13 Test argument.
7482
*/
7583
do_action(
7684
'wpforms_getresponse_provider_process_task_async_action_subscribe_after',
7785
$response,
7886
$request_args,
7987
$contact,
8088
$this->connection,
81-
$this->connection[ $test ],
82-
$this->connection(),
83-
$this->connection( $a, $b, $c ),
8489
[
8590
'form_data' => $this->form_data,
8691
'fields' => $this->fields,
8792
'entry' => $this->entry,
8893
],
94+
$this->connection[ $test ],
95+
$this->connection(),
96+
$this->connection( $a, $b, $c ),
8997
function () {
9098
return 'true';
9199
},
@@ -203,3 +211,27 @@ function () {
203211

204212
/** This filter is documented in wp-includes/post-template.php */
205213
$content = apply_filters( 'the_content', $content );
214+
215+
/**
216+
* Allow modifying the text or url for the full page on the AMP pages.
217+
*
218+
* @since 1.4.1.1
219+
* @since 1.7.1 Added $form_id, $full_page_url, and $form_data arguments.
220+
*
221+
* @param int $form_id Form id.
222+
* @param array $form_data Form data and settings.
223+
* @param array $form_data Form data and settings.
224+
* @param array $form_data Form data and settings.
225+
*
226+
* @return string
227+
*/
228+
$text = (string) apply_filters(
229+
'wpforms_frontend_shortcode_amp_text',
230+
sprintf( /* translators: %s - URL to a non-amp version of a page with the form. */
231+
__( '<a href="%s">Go to the full page</a> to view and submit the form.', 'wpforms-lite' ),
232+
esc_url( $full_page_url )
233+
),
234+
$form_id,
235+
$full_page_url,
236+
$form_data
237+
);

WPForms/Tests/Tests/Comments/ParamTagHooksTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ public function testProcess() {
2222
$phpcsFile = $this->process( new ParamTagHooksSniff() );
2323

2424
$this->fileHasErrors( $phpcsFile, 'InvalidAlign', [ 49, 50, 51, 52, 53 ] );
25-
$this->fileHasErrors( $phpcsFile, 'InvalidParamTagsQuantity', [ 75 ] );
26-
$this->fileHasErrors( $phpcsFile, 'MissParamInfo', [ 103, 104, 105, 106, 107, 108, 109 ] );
27-
$this->fileHasErrors( $phpcsFile, 'AddStopSymbol', [ 133, 134, 138 ] );
28-
$this->fileHasErrors( $phpcsFile, 'ExtraSpacesAfterParamTag', [ 160, 161, 162, 163, 164 ] );
25+
$this->fileHasErrors( $phpcsFile, 'InvalidParamTagsQuantity', [] );
26+
$this->fileHasErrors( $phpcsFile, 'MissParamInfo', [ 111, 112, 113, 114, 115, 116, 117 ] );
27+
$this->fileHasErrors( $phpcsFile, 'AddStopSymbol', [ 141, 142, 146 ] );
28+
$this->fileHasErrors( $phpcsFile, 'ExtraSpacesAfterParamTag', [ 168, 169, 170, 171, 172 ] );
2929
}
3030
}

0 commit comments

Comments
 (0)