Skip to content

Commit

Permalink
Implement a check for edge cases where the function name terminates w…
Browse files Browse the repository at this point in the history
…ith an underscore.
  • Loading branch information
anton-vlasenko committed Aug 10, 2023
1 parent 2542664 commit b7583d3
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ private function processFunctionToken( File $phpcsFile, $stackPointer ) {
$prefix = rtrim( $prefix, '_' );
$allowed_function_prefix = $prefix . '_' . $this->sanitize_directory_name( $parent_directory_name );
$allowed_function_prefixes[] = $allowed_function_prefix;
$is_function_name_valid |= 0 === strpos( $function_name, $allowed_function_prefix );
// Verify the validity of the name and ensure that a function name does not end with an underscore.
$regexp = sprintf( '/^%s(|_.+)$/', preg_quote( $allowed_function_prefix, '/' ) );
$is_function_name_valid |= (1 === preg_match( $regexp, $function_name ));
}

if ( $is_function_name_valid ) {
Expand Down

0 comments on commit b7583d3

Please sign in to comment.