Skip to content

Commit

Permalink
Allow runtime set in Abstract PHP Sniff class
Browse files Browse the repository at this point in the history
  • Loading branch information
ernilambar committed Sep 29, 2024
1 parent 6418d8d commit c0bd597
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions includes/Checker/Checks/Abstract_PHP_CodeSniffer_Check.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ abstract class Abstract_PHP_CodeSniffer_Check implements Static_Check {
* @var array
*/
protected $allowed_args = array(
'standard' => true,
'extensions' => true,
'sniffs' => true,
'exclude' => true, //phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude
'standard' => true,
'extensions' => true,
'sniffs' => true,
'runtime-set' => true,
'exclude' => true, //phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude
);

/**
Expand Down Expand Up @@ -145,7 +146,15 @@ private function parse_argv( $argv, $defaults ) {

// Format check arguments for PHPCS.
foreach ( $check_args as $key => $value ) {
$defaults[] = "--{$key}=$value";
if ( 'runtime-set' === $key ) {
if ( is_array( $value ) ) {
foreach ( $value as $runtime_item_key => $runtime_item_value ) {
$defaults = array_merge( $defaults, array( "--{$key}", $runtime_item_key, $runtime_item_value ) );

Check warning on line 152 in includes/Checker/Checks/Abstract_PHP_CodeSniffer_Check.php

View check run for this annotation

Codecov / codecov/patch

includes/Checker/Checks/Abstract_PHP_CodeSniffer_Check.php#L150-L152

Added lines #L150 - L152 were not covered by tests
}
}
} else {
$defaults[] = "--{$key}=$value";
}
}

return $defaults;
Expand Down

0 comments on commit c0bd597

Please sign in to comment.