Skip to content

Commit 6b3ffb9

Browse files
committed
Merge branch 'main' into try/os
2 parents 2aed0b8 + aaa3187 commit 6b3ffb9

File tree

6 files changed

+36
-19
lines changed

6 files changed

+36
-19
lines changed

.github/workflows/copilot-setup-steps.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717

1818
steps:
1919
- name: Checkout code
20-
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
20+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
2121

2222
- name: Check existence of composer.json file
2323
id: check_composer_file

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"phpstan/phpstan-phpunit": "^1.4 || ^2.0",
2222
"phpstan/phpstan-strict-rules": "^1.6 || ^2.0",
2323
"swissspidy/phpstan-no-private": "^0.2.1 || ^1.0",
24-
"szepeviktor/phpstan-wordpress": "^v1.3.5",
24+
"szepeviktor/phpstan-wordpress": "^1.3.5 || ^2.0.3",
2525
"wp-cli/config-command": "^1 || ^2",
2626
"wp-cli/core-command": "^1 || ^2",
2727
"wp-cli/eval-command": "^1 || ^2",

extension.neon

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ parameters:
2929
switchConditionsMatchingType: false
3030
noVariableVariables: false
3131
strictArrayFilter: false
32+
booleansInLoopConditions: false
33+
disallowedBacktick: false
34+
disallowedEmpty: false
35+
disallowedImplicitArrayCreation: false
36+
disallowedShortTernary: false
37+
strictFunctionCalls: false
38+
dynamicCallOnStaticMethod: false
39+
illegalConstructorMethodCall: false
3240

3341
# Add the schema from phpstan-strict-rules so it's available without loading the extension
3442
# and the above configuration works.
@@ -48,4 +56,12 @@ parametersSchema:
4856
switchConditionsMatchingType: anyOf(bool(), arrayOf(bool()))
4957
noVariableVariables: anyOf(bool(), arrayOf(bool()))
5058
strictArrayFilter: anyOf(bool(), arrayOf(bool()))
59+
booleansInLoopConditions: anyOf(bool(), arrayOf(bool()))
60+
disallowedBacktick: anyOf(bool(), arrayOf(bool()))
61+
disallowedEmpty: anyOf(bool(), arrayOf(bool()))
62+
disallowedImplicitArrayCreation: anyOf(bool(), arrayOf(bool()))
63+
disallowedShortTernary: anyOf(bool(), arrayOf(bool()))
64+
strictFunctionCalls: anyOf(bool(), arrayOf(bool()))
65+
dynamicCallOnStaticMethod: anyOf(bool(), arrayOf(bool()))
66+
illegalConstructorMethodCall: anyOf(bool(), arrayOf(bool()))
5167
])

phpstan.neon.dist

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,5 @@ parameters:
1919
- WP_DEBUG_LOG
2020
- WP_DEBUG_DISPLAY
2121
ignoreErrors:
22-
- message: '#Dynamic call to static method#'
23-
path: 'tests/tests'
2422
strictRules:
2523
strictCalls: true

src/Context/FeatureContext.php

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,8 @@ public function __construct() {
872872
if ( getenv( 'WP_CLI_TEST_DBTYPE' ) ) {
873873
$this->variables['DB_TYPE'] = getenv( 'WP_CLI_TEST_DBTYPE' );
874874
} else {
875-
$this->variables['DB_TYPE'] = 'mysql';
875+
// Auto-detect database type if not explicitly set
876+
$this->variables['DB_TYPE'] = Utils\get_db_type();
876877
}
877878

878879
if ( getenv( 'MYSQL_TCP_PORT' ) ) {
@@ -1210,7 +1211,7 @@ private function set_cache_dir(): void {
12101211
* Run a MySQL command with `$db_settings`.
12111212
*
12121213
* @param string $sql_cmd Command to run.
1213-
* @param array<string, string> $assoc_args Optional. Associative array of options. Default empty.
1214+
* @param array<string, string|bool> $assoc_args Optional. Associative array of options. Default empty.
12141215
* @param bool $add_database Optional. Whether to add dbname to the $sql_cmd. Default false.
12151216
* @return array{stdout: string, stderr: string, exit_code: int}
12161217
*/
@@ -1243,8 +1244,9 @@ public function create_db(): void {
12431244
return;
12441245
}
12451246

1246-
$dbname = self::$db_settings['dbname'];
1247-
self::run_sql( self::$mysql_binary . ' --no-defaults', [ 'execute' => "CREATE DATABASE IF NOT EXISTS $dbname" ] );
1247+
$dbname = self::$db_settings['dbname'];
1248+
$ssl_flag = 'mariadb' === self::$db_type ? ' --ssl-verify-server-cert' : '';
1249+
self::run_sql( self::$mysql_binary . ' --no-defaults' . $ssl_flag, [ 'execute' => "CREATE DATABASE IF NOT EXISTS $dbname" ] );
12481250
}
12491251

12501252
/**
@@ -1255,8 +1257,9 @@ public function test_connection(): void {
12551257
return;
12561258
}
12571259

1260+
$ssl_flag = 'mariadb' === self::$db_type ? ' --ssl-verify-server-cert' : '';
12581261
$sql_result = self::run_sql(
1259-
self::$mysql_binary . ' --no-defaults',
1262+
self::$mysql_binary . ' --no-defaults' . $ssl_flag,
12601263
[
12611264
'execute' => 'SELECT 1',
12621265
'send_to_shell' => false,
@@ -1282,13 +1285,14 @@ public function drop_db(): void {
12821285
if ( 'sqlite' === self::$db_type ) {
12831286
return;
12841287
}
1285-
$dbname = self::$db_settings['dbname'];
1286-
self::run_sql( self::$mysql_binary . ' --no-defaults', [ 'execute' => "DROP DATABASE IF EXISTS $dbname" ] );
1288+
$dbname = self::$db_settings['dbname'];
1289+
$ssl_flag = 'mariadb' === self::$db_type ? ' --ssl-verify-server-cert' : '';
1290+
self::run_sql( self::$mysql_binary . ' --no-defaults' . $ssl_flag, [ 'execute' => "DROP DATABASE IF EXISTS $dbname" ] );
12871291
}
12881292

12891293
/**
12901294
* @param string $command
1291-
* @param array<string, string> $assoc_args
1295+
* @param array<string, mixed> $assoc_args
12921296
* @param string $path
12931297
* @return Process
12941298
*/
@@ -1590,7 +1594,8 @@ public function install_wp( $subdir = '', $version = '' ): void {
15901594
if ( 'sqlite' === self::$db_type ) {
15911595
copy( "{$install_cache_path}.sqlite", "$run_dir/wp-content/database/.ht.sqlite" );
15921596
} else {
1593-
self::run_sql( self::$mysql_binary . ' --no-defaults', [ 'execute' => "source {$install_cache_path}.sql" ], true /*add_database*/ );
1597+
$ssl_flag = 'mariadb' === self::$db_type ? ' --ssl-verify-server-cert' : '';
1598+
self::run_sql( self::$mysql_binary . ' --no-defaults' . $ssl_flag, [ 'execute' => "source {$install_cache_path}.sql" ], true /*add_database*/ );
15941599
}
15951600
} else {
15961601
$this->proc( 'wp core install', $install_args, $subdir )->run_check();
@@ -1604,7 +1609,8 @@ public function install_wp( $subdir = '', $version = '' ): void {
16041609
$mysqldump_binary = Utils\force_env_on_nix_systems( $mysqldump_binary );
16051610
$help_output = shell_exec( "{$mysqldump_binary} --help" );
16061611
$support_column_statistics = false !== strpos( $help_output, 'column-statistics' );
1607-
$command = "{$mysqldump_binary} --no-defaults --no-tablespaces";
1612+
$ssl_flag = 'mariadb' === self::$db_type ? ' --ssl-verify-server-cert' : '';
1613+
$command = "{$mysqldump_binary} --no-defaults{$ssl_flag} --no-tablespaces";
16081614
if ( $support_column_statistics ) {
16091615
$command .= ' --skip-column-statistics';
16101616
}

src/PHPStan/WPCliRuncommandDynamicReturnTypeExtension.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,8 @@ public function getTypeFromStaticMethodCall(
3939
): Type {
4040
$args = $methodCall->getArgs();
4141

42-
/** @var ConstantBooleanType|ConstantStringType $returnOption */
43-
$returnOption = new ConstantBooleanType( true );
44-
/** @var ConstantBooleanType|ConstantStringType $parseOption */
45-
$parseOption = new ConstantBooleanType( false );
46-
/** @var ConstantBooleanType $exitOnErrorOption */
42+
$returnOption = new ConstantBooleanType( true );
43+
$parseOption = new ConstantBooleanType( false );
4744
$exitOnErrorOption = new ConstantBooleanType( true );
4845

4946
$optionsAreStaticallyKnown = true;

0 commit comments

Comments
 (0)