Skip to content

Commit 8d50385

Browse files
committed
Keep the scoping build scripts within the code quality checks
The static analysis config lints everything under `utils`, so the new build scripts need the same treatment the existing ones already get. * Exempt them from the two WordPress-context sniffs `make-phar.php` is already exempt from; they are procedural stand-alone scripts that never run inside WordPress. * Exclude `utils/scoper/scoper.inc.php` from PHPStan. It is an isolated toolchain with its own composer.json, so the classes it references are not installed in this project's vendor directory. * Swap `str_contains()` for `strpos()`. The script refuses to run below PHP 8.2, but phpcs checks this repository against a 7.2 baseline and flags the newer function. Refs wp-cli/wp-cli#5920 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RHtjyXkZh8X16sBgmidSQi
1 parent b457650 commit 8d50385

3 files changed

Lines changed: 13 additions & 1 deletion

File tree

‎phpcs.xml.dist‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,14 @@
5252
<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
5353
<exclude-pattern>*/utils/get-package-require-from-composer\.php$</exclude-pattern>
5454
<exclude-pattern>*/utils/make-phar\.php$</exclude-pattern>
55+
<exclude-pattern>*/utils/scope-dependencies\.php$</exclude-pattern>
56+
<exclude-pattern>*/utils/scoper/scoper\.inc\.php$</exclude-pattern>
5557
</rule>
5658
<rule ref="WordPress.WP.GlobalVariablesOverride">
5759
<exclude-pattern>*/utils/get-package-require-from-composer\.php$</exclude-pattern>
5860
<exclude-pattern>*/utils/make-phar\.php$</exclude-pattern>
61+
<exclude-pattern>*/utils/scope-dependencies\.php$</exclude-pattern>
62+
<exclude-pattern>*/utils/scoper/scoper\.inc\.php$</exclude-pattern>
5963
</rule>
6064

6165
</ruleset>

‎phpstan.neon.dist‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ parameters:
33
paths:
44
- php
55
- utils
6+
excludePaths:
7+
analyse:
8+
# Isolated toolchain with its own composer.json; its dependencies are not
9+
# installed in this project's vendor directory.
10+
- utils/scoper/scoper.inc.php
611
scanDirectories:
712
- vendor/wp-cli/wp-cli
813
scanFiles:

‎utils/scope-dependencies.php‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,10 @@ function fail( string $message ): void {
286286

287287
$classmap = $vendor_dir . '/composer/autoload_classmap.php';
288288

289-
if ( file_exists( $classmap ) && ! str_contains( (string) file_get_contents( $classmap ), 'WP_CLI\\\\Vendor\\\\' ) ) {
289+
// strpos() rather than str_contains() so the file still parses under the 7.2
290+
// baseline phpcs checks this repository against, even though the script itself
291+
// refuses to run on anything below PHP 8.2.
292+
if ( file_exists( $classmap ) && false === strpos( (string) file_get_contents( $classmap ), 'WP_CLI\\\\Vendor\\\\' ) ) {
290293
fail( 'The regenerated classmap contains no prefixed classes at all; the prefixing step did not take effect.' );
291294
}
292295

0 commit comments

Comments
 (0)