Skip to content

Commit 6fd70ff

Browse files
committed
Upgrade wp-cli-tests to v5
The dev-develop branch of phpcompatibility/php-compatibility now requires squizlabs/php_codesniffer ^4, which conflicts with the ^3 required by wp-cli-tests v4. Additionally, the shared CI workflow (wp-cli/.github#208) now runs code coverage on PHP 8.5, which needs the newer php-code-coverage library from v5. Changes: - Upgrade wp-cli/wp-cli-tests from ^4.3.2 to ^5.0. - Add phpcompatibility/php-compatibility ^10.0@alpha and wp-coding-standards/wpcs @dev to satisfy transitive deps that lack stable releases. - Add phpstan script and config, required by wp-cli-tests v5. - Add stubs for WP_SQLite_Driver, WP_SQLite_Translator, and WP_SQLite_Connection (loaded at runtime by WordPress, not available via Composer). - Allow phpstan/extension-installer Composer plugin.
1 parent fcc0898 commit 6fd70ff

3 files changed

Lines changed: 49 additions & 3 deletions

File tree

‎composer.json‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,17 @@
2828
"wp-cli/wp-cli": "^2.5"
2929
},
3030
"require-dev": {
31-
"wp-cli/wp-cli-tests": "^4.3.2",
32-
"phpcompatibility/php-compatibility": "dev-develop"
31+
"wp-cli/wp-cli-tests": "^5.0",
32+
"phpcompatibility/php-compatibility": "^10.0@alpha",
33+
"wp-coding-standards/wpcs": "@dev"
3334
},
3435
"scripts": {
3536
"behat": "run-behat-tests",
3637
"behat-rerun": "rerun-behat-tests",
3738
"lint": "run-linter-tests",
3839
"phpcs": "run-phpcs-tests",
3940
"phpcbf": "run-phpcbf-cleanup",
41+
"phpstan": "run-phpstan-tests",
4042
"phpunit": "run-php-unit-tests",
4143
"prepare-tests": "install-package-tests",
4244
"test": [
@@ -48,7 +50,8 @@
4850
},
4951
"config": {
5052
"allow-plugins": {
51-
"dealerdirect/phpcodesniffer-composer-installer": true
53+
"dealerdirect/phpcodesniffer-composer-installer": true,
54+
"phpstan/extension-installer": true
5255
}
5356
}
5457
}

‎phpstan.neon.dist‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
parameters:
2+
level: 0
3+
paths:
4+
- src
5+
- command.php
6+
scanDirectories:
7+
- vendor/wp-cli/wp-cli/php
8+
scanFiles:
9+
- vendor/php-stubs/wordpress-stubs/wordpress-stubs.php
10+
- phpstan/stubs.php
11+
treatPhpDocTypesAsCertain: false
12+
dynamicConstantNames:
13+
- WP_DEBUG
14+
- WP_DEBUG_LOG
15+
- WP_DEBUG_DISPLAY

‎phpstan/stubs.php‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
/**
3+
* Stubs for the WordPress SQLite integration plugin classes.
4+
*
5+
* These classes are loaded at runtime by WordPress, not via Composer.
6+
* The stubs allow PHPStan to analyze code that references them.
7+
*/
8+
9+
class WP_SQLite_Connection {
10+
/**
11+
* @param array{path: string} $config
12+
*/
13+
public function __construct( array $config ) {}
14+
public function quote_identifier( string $identifier ): string {}
15+
public function get_pdo(): PDO {}
16+
}
17+
18+
class WP_SQLite_Driver {
19+
public function __construct( WP_SQLite_Connection $connection, string $db_name ) {}
20+
public function query( string $sql ) {}
21+
public function get_connection(): WP_SQLite_Connection {}
22+
}
23+
24+
class WP_SQLite_Translator {
25+
public function __construct() {}
26+
public function query( string $sql ) {}
27+
public function get_pdo(): PDO {}
28+
}

0 commit comments

Comments
 (0)