From 6de99d4ec3ce6687e6c486a0b5977332db745186 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Thu, 23 Jul 2026 14:20:39 +0200 Subject: [PATCH 1/9] Add PHPCS linting for PHP blocks in feature files --- bin/run-phpcs-tests | 25 +++- utils/extract-feature-php.php | 236 ++++++++++++++++++++++++++++++++++ 2 files changed, 259 insertions(+), 2 deletions(-) create mode 100644 utils/extract-feature-php.php diff --git a/bin/run-phpcs-tests b/bin/run-phpcs-tests index 82d96b4e5..12e42efdb 100755 --- a/bin/run-phpcs-tests +++ b/bin/run-phpcs-tests @@ -1,7 +1,28 @@ #!/bin/sh -# Run the code style check only if a configuration file exists. +EXIT_CODE=0 + +# 1. Run standard PHP code style check if a configuration file exists. if [ -f ".phpcs.xml" ] || [ -f "phpcs.xml" ] || [ -f ".phpcs.xml.dist" ] || [ -f "phpcs.xml.dist" ] then - vendor/bin/phpcs "$@" + vendor/bin/phpcs "$@" || EXIT_CODE=$? fi + +# 2. Run PHPCS over extracted PHP blocks in .feature files if features/ directory exists. +DIR="$(cd "$(dirname "$0")/.." && pwd)" +if [ -d "features" ] && [ -f "$DIR/utils/extract-feature-php.php" ] +then + TEMP_DIR=$(mktemp -d 2>/dev/null || mktemp -d -t 'feature_phpcs') + trap 'rm -rf "$TEMP_DIR"' EXIT HUP INT TERM + + php "$DIR/utils/extract-feature-php.php" extract features "$TEMP_DIR" >/dev/null 2>&1 + + if [ -d "$TEMP_DIR" ] && [ "$(ls -A "$TEMP_DIR" 2>/dev/null)" ] + then + vendor/bin/phpcs --standard=WP_CLI_CS --warning-severity=0 \ + --exclude=Generic.Files.InlineHTML,Generic.Files.LineEndings,WordPress.Files.FileName,Squiz.Commenting.FileComment,Generic.WhiteSpace.DisallowSpaceIndent,Universal.WhiteSpace.PrecisionAlignment,PSR2.Files.EndFileNewline,PSR2.Methods.FunctionClosingBrace,Generic.PHP.CharacterBeforePHPOpenTag,Generic.PHP.RequireStrictTypes,Squiz.WhiteSpace.SuperfluousWhitespace \ + "$TEMP_DIR" 2>&1 | sed -E 's/\.feature_L[0-9]+_E[0-9]+_(HASPHP|NOPHP)\.php/.feature/g' | sed -E "s|FILE: .*/([^/]+\.feature)|FILE: features/\1|g" || EXIT_CODE=$? + fi +fi + +exit $EXIT_CODE diff --git a/utils/extract-feature-php.php b/utils/extract-feature-php.php new file mode 100644 index 000000000..8d3683cbd --- /dev/null +++ b/utils/extract-feature-php.php @@ -0,0 +1,236 @@ +isDir() ? 'rmdir' : 'unlink' ); + $todo( $fileinfo->getRealPath() ); + } + } + + $directory = new RecursiveDirectoryIterator( $source_dir ); + $iterator = new RecursiveIteratorIterator( $directory ); + + foreach ( $iterator as $file ) { + if ( $file->isFile() && 'feature' === $file->getExtension() ) { + $filepath = $file->getPathname(); + $relative = substr( $filepath, strlen( $source_dir ) + 1 ); + $lines = file( $filepath ); + + $in_docstring = false; + $is_php_block = false; + $docstring_lines = []; + $start_line = 0; + + foreach ( $lines as $index => $line ) { + $trimmed = trim( $line ); + + if ( 0 === strpos( $trimmed, '"""' ) || 0 === strpos( $trimmed, "'''" ) ) { + if ( ! $in_docstring ) { + $in_docstring = true; + $is_php_block = false; + $docstring_lines = []; + $start_line = $index; + + if ( $index > 0 && preg_match( '/\b[\w\/-]+\.php\b/i', $lines[ $index - 1 ] ) ) { + $is_php_block = true; + } + } else { + $in_docstring = false; + if ( $is_php_block && ! empty( $docstring_lines ) ) { + $min_indent = PHP_INT_MAX; + foreach ( $docstring_lines as $code_line ) { + if ( '' !== trim( $code_line ) ) { + preg_match( '/^\s*/', $code_line, $m ); + $min_indent = min( $min_indent, strlen( $m[0] ) ); + } + } + if ( PHP_INT_MAX === $min_indent ) { + $min_indent = 0; + } + + $has_php_tag = false; + foreach ( $docstring_lines as $code_line ) { + if ( '' !== trim( $code_line ) ) { + if ( 0 === strpos( trim( $code_line ), ' $code_line ) { + $out_lines[ $line_idx ] = substr( $code_line, $min_indent ); + } + + $end_line = $index; + $php_flag = $has_php_tag ? 'HASPHP' : 'NOPHP'; + $target_file = $target_dir . '/' . $relative . '_L' . ( $start_line + 1 ) . '_E' . ( $end_line + 1 ) . '_' . $php_flag . '.php'; + + $target_subdir = dirname( $target_file ); + if ( ! is_dir( $target_subdir ) ) { + mkdir( $target_subdir, 0777, true ); + } + file_put_contents( $target_file, implode( '', $out_lines ) ); + } + } + continue; + } + + if ( $in_docstring ) { + $docstring_count = count( $docstring_lines ); + if ( 0 === $docstring_count && 0 === strpos( $trimmed, 'isFile() && 'php' === $file->getExtension() ) { + $temp_filepath = $file->getPathname(); + $temp_filename = $file->getFilename(); + + if ( ! preg_match( '/^(.*\.feature)_L(\d+)_E(\d+)_(HASPHP|NOPHP)\.php$/', $temp_filename, $matches ) ) { + continue; + } + + $sub_path = substr( dirname( $temp_filepath ), strlen( $target_dir ) ); + $feature_rel_path = ( '' !== $sub_path ? $sub_path . '/' : '' ) . $matches[1]; + $feature_path = $source_dir . '/' . ltrim( $feature_rel_path, '/' ); + + $files_by_feature[ $feature_path ][] = [ + 'temp_filepath' => $temp_filepath, + 'docstring_start' => (int) $matches[2] - 1, + 'docstring_end' => (int) $matches[3] - 1, + 'had_php_tag' => 'HASPHP' === $matches[4], + ]; + } + } + + foreach ( $files_by_feature as $feature_path => $blocks ) { + if ( ! file_exists( $feature_path ) ) { + continue; + } + + usort( + $blocks, + function ( $a, $b ) { + return $b['docstring_start'] <=> $a['docstring_start']; + } + ); + + $feature_lines = file( $feature_path ); + + foreach ( $blocks as $block ) { + $code_start = $block['docstring_start'] + 1; + $code_end = $block['docstring_end'] - 1; + $had_php_tag = $block['had_php_tag']; + $temp_lines = file( $block['temp_filepath'] ); + + if ( ! isset( $feature_lines[ $code_start ] ) || $code_start > $code_end ) { + continue; + } + + preg_match( '/^\s*/', $feature_lines[ $code_start ], $m ); + $indent = $m[0] ?? ' '; + + $code_lines = []; + foreach ( $temp_lines as $temp_line ) { + if ( ! $had_php_tag && false !== strpos( $temp_line, 'added_php_tag' ) ) { + continue; + } + $code_lines[] = $temp_line; + } + + while ( ! empty( $code_lines ) && '' === trim( reset( $code_lines ) ) ) { + array_shift( $code_lines ); + } + while ( ! empty( $code_lines ) && '' === trim( end( $code_lines ) ) ) { + array_pop( $code_lines ); + } + + $fixed_lines = []; + foreach ( $code_lines as $line_content ) { + if ( '' === trim( $line_content ) ) { + $fixed_lines[] = "\n"; + } else { + $fixed_lines[] = $indent . ltrim( $line_content ); + } + } + + $num_code_lines = ( $code_end - $code_start + 1 ); + array_splice( $feature_lines, $code_start, $num_code_lines, $fixed_lines ); + } + + file_put_contents( $feature_path, implode( '', $feature_lines ) ); + } +} + +$wp_cli_tests_action = $argv[1] ?? 'extract'; +if ( 'update' === $wp_cli_tests_action ) { + update_feature_php( $argv[2] ?? '', $argv[3] ?? '' ); +} else { + extract_feature_php( $argv[2] ?? $argv[1] ?? '', $argv[3] ?? $argv[2] ?? '' ); +} From 1f954c8976f401ab118e702668e5ef965c0a4b0d Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Thu, 23 Jul 2026 14:20:44 +0200 Subject: [PATCH 2/9] Add PHPCBF support for feature files --- bin/run-phpcbf-cleanup | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/bin/run-phpcbf-cleanup b/bin/run-phpcbf-cleanup index f7a4d8fb1..ec2fd8134 100755 --- a/bin/run-phpcbf-cleanup +++ b/bin/run-phpcbf-cleanup @@ -1,7 +1,30 @@ #!/bin/sh -# Run the code style check only if a configuration file exists. +EXIT_CODE=0 + +# 1. Run standard PHPCBF if configuration file exists. if [ -f ".phpcs.xml" ] || [ -f "phpcs.xml" ] || [ -f ".phpcs.xml.dist" ] || [ -f "phpcs.xml.dist" ] then - vendor/bin/phpcbf "$@" + vendor/bin/phpcbf "$@" || EXIT_CODE=$? +fi + +# 2. Run PHPCBF over extracted PHP blocks in .feature files and sync back fixes. +DIR="$(cd "$(dirname "$0")/.." && pwd)" +if [ -d "features" ] && [ -f "$DIR/utils/extract-feature-php.php" ] +then + TEMP_DIR=$(mktemp -d 2>/dev/null || mktemp -d -t 'feature_phpcbf') + trap 'rm -rf "$TEMP_DIR"' EXIT HUP INT TERM + + php "$DIR/utils/extract-feature-php.php" extract features "$TEMP_DIR" >/dev/null 2>&1 + + if [ -d "$TEMP_DIR" ] && [ "$(ls -A "$TEMP_DIR" 2>/dev/null)" ] + then + vendor/bin/phpcbf --standard=WP_CLI_CS \ + --exclude=Generic.Files.InlineHTML,Generic.Files.LineEndings,WordPress.Files.FileName,Squiz.Commenting.FileComment,Generic.WhiteSpace.DisallowSpaceIndent,Universal.WhiteSpace.PrecisionAlignment,PSR2.Files.EndFileNewline,PSR2.Methods.FunctionClosingBrace,Generic.PHP.CharacterBeforePHPOpenTag,Generic.PHP.RequireStrictTypes,Squiz.WhiteSpace.SuperfluousWhitespace \ + "$TEMP_DIR" >/dev/null 2>&1 + + php "$DIR/utils/extract-feature-php.php" update features "$TEMP_DIR" >/dev/null 2>&1 + fi fi + +exit $EXIT_CODE From af59387eff30a288c9f996d6b830fc204c0c3cc7 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Thu, 23 Jul 2026 14:20:50 +0200 Subject: [PATCH 3/9] Fix PHP code style violations in feature files --- features/behat-steps.feature | 2 +- features/testing.feature | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/features/behat-steps.feature b/features/behat-steps.feature index 431f56e9c..6dc5874bd 100644 --- a/features/behat-steps.feature +++ b/features/behat-steps.feature @@ -549,7 +549,7 @@ Feature: Test that WP-CLI Behat steps work as expected And a send-email.php file: """ Date: Thu, 23 Jul 2026 14:33:37 +0200 Subject: [PATCH 4/9] Preserve relative PHP code indentation during PHPCBF update --- utils/extract-feature-php.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/extract-feature-php.php b/utils/extract-feature-php.php index 8d3683cbd..72f002710 100644 --- a/utils/extract-feature-php.php +++ b/utils/extract-feature-php.php @@ -216,7 +216,7 @@ function ( $a, $b ) { if ( '' === trim( $line_content ) ) { $fixed_lines[] = "\n"; } else { - $fixed_lines[] = $indent . ltrim( $line_content ); + $fixed_lines[] = $indent . $line_content; } } From f7e89ee4d7c0d817a385b4abf43b527a63b073be Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Thu, 23 Jul 2026 16:08:47 +0200 Subject: [PATCH 5/9] Preserve empty lines inside feature PHP blocks during extraction --- utils/extract-feature-php.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/utils/extract-feature-php.php b/utils/extract-feature-php.php index 72f002710..30cb7d5a0 100644 --- a/utils/extract-feature-php.php +++ b/utils/extract-feature-php.php @@ -96,7 +96,11 @@ function extract_feature_php( $source_dir, $target_dir ) { } foreach ( $docstring_lines as $line_idx => $code_line ) { - $out_lines[ $line_idx ] = substr( $code_line, $min_indent ); + if ( '' === trim( $code_line ) ) { + $out_lines[ $line_idx ] = "\n"; + } else { + $out_lines[ $line_idx ] = substr( $code_line, $min_indent ); + } } $end_line = $index; From 9d3728ca8b700688578fdc424d180c4104bb9028 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Thu, 23 Jul 2026 16:17:35 +0200 Subject: [PATCH 6/9] Enforce standard tab indentation inside feature PHP snippets --- bin/run-phpcbf-cleanup | 2 +- bin/run-phpcs-tests | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/run-phpcbf-cleanup b/bin/run-phpcbf-cleanup index ec2fd8134..8ffcdea83 100755 --- a/bin/run-phpcbf-cleanup +++ b/bin/run-phpcbf-cleanup @@ -20,7 +20,7 @@ then if [ -d "$TEMP_DIR" ] && [ "$(ls -A "$TEMP_DIR" 2>/dev/null)" ] then vendor/bin/phpcbf --standard=WP_CLI_CS \ - --exclude=Generic.Files.InlineHTML,Generic.Files.LineEndings,WordPress.Files.FileName,Squiz.Commenting.FileComment,Generic.WhiteSpace.DisallowSpaceIndent,Universal.WhiteSpace.PrecisionAlignment,PSR2.Files.EndFileNewline,PSR2.Methods.FunctionClosingBrace,Generic.PHP.CharacterBeforePHPOpenTag,Generic.PHP.RequireStrictTypes,Squiz.WhiteSpace.SuperfluousWhitespace \ + --exclude=Generic.Files.InlineHTML,Generic.Files.LineEndings,WordPress.Files.FileName,Squiz.Commenting.FileComment,Universal.WhiteSpace.PrecisionAlignment,PSR2.Files.EndFileNewline,PSR2.Methods.FunctionClosingBrace,Generic.PHP.CharacterBeforePHPOpenTag,Generic.PHP.RequireStrictTypes,Squiz.WhiteSpace.SuperfluousWhitespace \ "$TEMP_DIR" >/dev/null 2>&1 php "$DIR/utils/extract-feature-php.php" update features "$TEMP_DIR" >/dev/null 2>&1 diff --git a/bin/run-phpcs-tests b/bin/run-phpcs-tests index 12e42efdb..3a2a4cafe 100755 --- a/bin/run-phpcs-tests +++ b/bin/run-phpcs-tests @@ -20,7 +20,7 @@ then if [ -d "$TEMP_DIR" ] && [ "$(ls -A "$TEMP_DIR" 2>/dev/null)" ] then vendor/bin/phpcs --standard=WP_CLI_CS --warning-severity=0 \ - --exclude=Generic.Files.InlineHTML,Generic.Files.LineEndings,WordPress.Files.FileName,Squiz.Commenting.FileComment,Generic.WhiteSpace.DisallowSpaceIndent,Universal.WhiteSpace.PrecisionAlignment,PSR2.Files.EndFileNewline,PSR2.Methods.FunctionClosingBrace,Generic.PHP.CharacterBeforePHPOpenTag,Generic.PHP.RequireStrictTypes,Squiz.WhiteSpace.SuperfluousWhitespace \ + --exclude=Generic.Files.InlineHTML,Generic.Files.LineEndings,WordPress.Files.FileName,Squiz.Commenting.FileComment,Universal.WhiteSpace.PrecisionAlignment,PSR2.Files.EndFileNewline,PSR2.Methods.FunctionClosingBrace,Generic.PHP.CharacterBeforePHPOpenTag,Generic.PHP.RequireStrictTypes,Squiz.WhiteSpace.SuperfluousWhitespace \ "$TEMP_DIR" 2>&1 | sed -E 's/\.feature_L[0-9]+_E[0-9]+_(HASPHP|NOPHP)\.php/.feature/g' | sed -E "s|FILE: .*/([^/]+\.feature)|FILE: features/\1|g" || EXIT_CODE=$? fi fi From d6304a348399848a633304d2c83f684dfdd78b0a Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Thu, 23 Jul 2026 16:41:44 +0200 Subject: [PATCH 7/9] Exclude WordPress.NamingConventions.PrefixAllGlobals from feature file sniffs --- bin/run-phpcbf-cleanup | 2 +- bin/run-phpcs-tests | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/run-phpcbf-cleanup b/bin/run-phpcbf-cleanup index 8ffcdea83..61095f4f2 100755 --- a/bin/run-phpcbf-cleanup +++ b/bin/run-phpcbf-cleanup @@ -20,7 +20,7 @@ then if [ -d "$TEMP_DIR" ] && [ "$(ls -A "$TEMP_DIR" 2>/dev/null)" ] then vendor/bin/phpcbf --standard=WP_CLI_CS \ - --exclude=Generic.Files.InlineHTML,Generic.Files.LineEndings,WordPress.Files.FileName,Squiz.Commenting.FileComment,Universal.WhiteSpace.PrecisionAlignment,PSR2.Files.EndFileNewline,PSR2.Methods.FunctionClosingBrace,Generic.PHP.CharacterBeforePHPOpenTag,Generic.PHP.RequireStrictTypes,Squiz.WhiteSpace.SuperfluousWhitespace \ + --exclude=Generic.Files.InlineHTML,Generic.Files.LineEndings,WordPress.Files.FileName,Squiz.Commenting.FileComment,Universal.WhiteSpace.PrecisionAlignment,PSR2.Files.EndFileNewline,PSR2.Methods.FunctionClosingBrace,Generic.PHP.CharacterBeforePHPOpenTag,Generic.PHP.RequireStrictTypes,Squiz.WhiteSpace.SuperfluousWhitespace,WordPress.NamingConventions.PrefixAllGlobals \ "$TEMP_DIR" >/dev/null 2>&1 php "$DIR/utils/extract-feature-php.php" update features "$TEMP_DIR" >/dev/null 2>&1 diff --git a/bin/run-phpcs-tests b/bin/run-phpcs-tests index 3a2a4cafe..72250d4fd 100755 --- a/bin/run-phpcs-tests +++ b/bin/run-phpcs-tests @@ -20,7 +20,7 @@ then if [ -d "$TEMP_DIR" ] && [ "$(ls -A "$TEMP_DIR" 2>/dev/null)" ] then vendor/bin/phpcs --standard=WP_CLI_CS --warning-severity=0 \ - --exclude=Generic.Files.InlineHTML,Generic.Files.LineEndings,WordPress.Files.FileName,Squiz.Commenting.FileComment,Universal.WhiteSpace.PrecisionAlignment,PSR2.Files.EndFileNewline,PSR2.Methods.FunctionClosingBrace,Generic.PHP.CharacterBeforePHPOpenTag,Generic.PHP.RequireStrictTypes,Squiz.WhiteSpace.SuperfluousWhitespace \ + --exclude=Generic.Files.InlineHTML,Generic.Files.LineEndings,WordPress.Files.FileName,Squiz.Commenting.FileComment,Universal.WhiteSpace.PrecisionAlignment,PSR2.Files.EndFileNewline,PSR2.Methods.FunctionClosingBrace,Generic.PHP.CharacterBeforePHPOpenTag,Generic.PHP.RequireStrictTypes,Squiz.WhiteSpace.SuperfluousWhitespace,WordPress.NamingConventions.PrefixAllGlobals \ "$TEMP_DIR" 2>&1 | sed -E 's/\.feature_L[0-9]+_E[0-9]+_(HASPHP|NOPHP)\.php/.feature/g' | sed -E "s|FILE: .*/([^/]+\.feature)|FILE: features/\1|g" || EXIT_CODE=$? fi fi From 780a76b4b19e674ebdde45bb4140a6d65e95b93c Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Thu, 23 Jul 2026 17:54:59 +0200 Subject: [PATCH 8/9] Exclude OO structure and global override rules from feature file sniffs --- bin/run-phpcbf-cleanup | 2 +- bin/run-phpcs-tests | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/run-phpcbf-cleanup b/bin/run-phpcbf-cleanup index 61095f4f2..eacfab3a2 100755 --- a/bin/run-phpcbf-cleanup +++ b/bin/run-phpcbf-cleanup @@ -20,7 +20,7 @@ then if [ -d "$TEMP_DIR" ] && [ "$(ls -A "$TEMP_DIR" 2>/dev/null)" ] then vendor/bin/phpcbf --standard=WP_CLI_CS \ - --exclude=Generic.Files.InlineHTML,Generic.Files.LineEndings,WordPress.Files.FileName,Squiz.Commenting.FileComment,Universal.WhiteSpace.PrecisionAlignment,PSR2.Files.EndFileNewline,PSR2.Methods.FunctionClosingBrace,Generic.PHP.CharacterBeforePHPOpenTag,Generic.PHP.RequireStrictTypes,Squiz.WhiteSpace.SuperfluousWhitespace,WordPress.NamingConventions.PrefixAllGlobals \ + --exclude=Generic.Files.InlineHTML,Generic.Files.LineEndings,WordPress.Files.FileName,Squiz.Commenting.FileComment,Universal.WhiteSpace.PrecisionAlignment,PSR2.Files.EndFileNewline,PSR2.Methods.FunctionClosingBrace,Generic.PHP.CharacterBeforePHPOpenTag,Generic.PHP.RequireStrictTypes,Squiz.WhiteSpace.SuperfluousWhitespace,WordPress.NamingConventions.PrefixAllGlobals,Universal.Files.SeparateFunctionsFromOO,Generic.Files.OneObjectStructurePerFile,WordPress.WP.GlobalVariablesOverride,Universal.Namespaces.OneDeclarationPerFile,Universal.Namespaces.DisallowCurlyBraceSyntax \ "$TEMP_DIR" >/dev/null 2>&1 php "$DIR/utils/extract-feature-php.php" update features "$TEMP_DIR" >/dev/null 2>&1 diff --git a/bin/run-phpcs-tests b/bin/run-phpcs-tests index 72250d4fd..fa4614ee0 100755 --- a/bin/run-phpcs-tests +++ b/bin/run-phpcs-tests @@ -20,7 +20,7 @@ then if [ -d "$TEMP_DIR" ] && [ "$(ls -A "$TEMP_DIR" 2>/dev/null)" ] then vendor/bin/phpcs --standard=WP_CLI_CS --warning-severity=0 \ - --exclude=Generic.Files.InlineHTML,Generic.Files.LineEndings,WordPress.Files.FileName,Squiz.Commenting.FileComment,Universal.WhiteSpace.PrecisionAlignment,PSR2.Files.EndFileNewline,PSR2.Methods.FunctionClosingBrace,Generic.PHP.CharacterBeforePHPOpenTag,Generic.PHP.RequireStrictTypes,Squiz.WhiteSpace.SuperfluousWhitespace,WordPress.NamingConventions.PrefixAllGlobals \ + --exclude=Generic.Files.InlineHTML,Generic.Files.LineEndings,WordPress.Files.FileName,Squiz.Commenting.FileComment,Universal.WhiteSpace.PrecisionAlignment,PSR2.Files.EndFileNewline,PSR2.Methods.FunctionClosingBrace,Generic.PHP.CharacterBeforePHPOpenTag,Generic.PHP.RequireStrictTypes,Squiz.WhiteSpace.SuperfluousWhitespace,WordPress.NamingConventions.PrefixAllGlobals,Universal.Files.SeparateFunctionsFromOO,Generic.Files.OneObjectStructurePerFile,WordPress.WP.GlobalVariablesOverride,Universal.Namespaces.OneDeclarationPerFile,Universal.Namespaces.DisallowCurlyBraceSyntax \ "$TEMP_DIR" 2>&1 | sed -E 's/\.feature_L[0-9]+_E[0-9]+_(HASPHP|NOPHP)\.php/.feature/g' | sed -E "s|FILE: .*/([^/]+\.feature)|FILE: features/\1|g" || EXIT_CODE=$? fi fi From b32a615f1f03a9d0c603b237644a016b121e4800 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Thu, 23 Jul 2026 18:03:52 +0200 Subject: [PATCH 9/9] Exclude YodaConditions, empty catch, unnamed namespaces, and file header sniffs from feature PHP blocks --- bin/run-phpcbf-cleanup | 2 +- bin/run-phpcs-tests | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/run-phpcbf-cleanup b/bin/run-phpcbf-cleanup index eacfab3a2..bf1e38823 100755 --- a/bin/run-phpcbf-cleanup +++ b/bin/run-phpcbf-cleanup @@ -20,7 +20,7 @@ then if [ -d "$TEMP_DIR" ] && [ "$(ls -A "$TEMP_DIR" 2>/dev/null)" ] then vendor/bin/phpcbf --standard=WP_CLI_CS \ - --exclude=Generic.Files.InlineHTML,Generic.Files.LineEndings,WordPress.Files.FileName,Squiz.Commenting.FileComment,Universal.WhiteSpace.PrecisionAlignment,PSR2.Files.EndFileNewline,PSR2.Methods.FunctionClosingBrace,Generic.PHP.CharacterBeforePHPOpenTag,Generic.PHP.RequireStrictTypes,Squiz.WhiteSpace.SuperfluousWhitespace,WordPress.NamingConventions.PrefixAllGlobals,Universal.Files.SeparateFunctionsFromOO,Generic.Files.OneObjectStructurePerFile,WordPress.WP.GlobalVariablesOverride,Universal.Namespaces.OneDeclarationPerFile,Universal.Namespaces.DisallowCurlyBraceSyntax \ + --exclude=Generic.Files.InlineHTML,Generic.Files.LineEndings,WordPress.Files.FileName,Squiz.Commenting.FileComment,Universal.WhiteSpace.PrecisionAlignment,PSR2.Files.EndFileNewline,PSR2.Methods.FunctionClosingBrace,Generic.PHP.CharacterBeforePHPOpenTag,Generic.PHP.RequireStrictTypes,Squiz.WhiteSpace.SuperfluousWhitespace,WordPress.NamingConventions.PrefixAllGlobals,Universal.Files.SeparateFunctionsFromOO,Generic.Files.OneObjectStructurePerFile,WordPress.WP.GlobalVariablesOverride,Universal.Namespaces.OneDeclarationPerFile,Universal.Namespaces.DisallowCurlyBraceSyntax,WordPress.PHP.YodaConditions,Universal.Namespaces.DisallowDeclarationWithoutName,PSR12.Files.FileHeader,Generic.CodeAnalysis.EmptyStatement \ "$TEMP_DIR" >/dev/null 2>&1 php "$DIR/utils/extract-feature-php.php" update features "$TEMP_DIR" >/dev/null 2>&1 diff --git a/bin/run-phpcs-tests b/bin/run-phpcs-tests index fa4614ee0..d8d86025d 100755 --- a/bin/run-phpcs-tests +++ b/bin/run-phpcs-tests @@ -20,7 +20,7 @@ then if [ -d "$TEMP_DIR" ] && [ "$(ls -A "$TEMP_DIR" 2>/dev/null)" ] then vendor/bin/phpcs --standard=WP_CLI_CS --warning-severity=0 \ - --exclude=Generic.Files.InlineHTML,Generic.Files.LineEndings,WordPress.Files.FileName,Squiz.Commenting.FileComment,Universal.WhiteSpace.PrecisionAlignment,PSR2.Files.EndFileNewline,PSR2.Methods.FunctionClosingBrace,Generic.PHP.CharacterBeforePHPOpenTag,Generic.PHP.RequireStrictTypes,Squiz.WhiteSpace.SuperfluousWhitespace,WordPress.NamingConventions.PrefixAllGlobals,Universal.Files.SeparateFunctionsFromOO,Generic.Files.OneObjectStructurePerFile,WordPress.WP.GlobalVariablesOverride,Universal.Namespaces.OneDeclarationPerFile,Universal.Namespaces.DisallowCurlyBraceSyntax \ + --exclude=Generic.Files.InlineHTML,Generic.Files.LineEndings,WordPress.Files.FileName,Squiz.Commenting.FileComment,Universal.WhiteSpace.PrecisionAlignment,PSR2.Files.EndFileNewline,PSR2.Methods.FunctionClosingBrace,Generic.PHP.CharacterBeforePHPOpenTag,Generic.PHP.RequireStrictTypes,Squiz.WhiteSpace.SuperfluousWhitespace,WordPress.NamingConventions.PrefixAllGlobals,Universal.Files.SeparateFunctionsFromOO,Generic.Files.OneObjectStructurePerFile,WordPress.WP.GlobalVariablesOverride,Universal.Namespaces.OneDeclarationPerFile,Universal.Namespaces.DisallowCurlyBraceSyntax,WordPress.PHP.YodaConditions,Universal.Namespaces.DisallowDeclarationWithoutName,PSR12.Files.FileHeader,Generic.CodeAnalysis.EmptyStatement \ "$TEMP_DIR" 2>&1 | sed -E 's/\.feature_L[0-9]+_E[0-9]+_(HASPHP|NOPHP)\.php/.feature/g' | sed -E "s|FILE: .*/([^/]+\.feature)|FILE: features/\1|g" || EXIT_CODE=$? fi fi