Skip to content

Commit 45570dd

Browse files
authored
Merge pull request #83 from wp-cli/dependabot/composer/wp-cli/wp-cli-tests-tw-5.0.0
2 parents 0c20336 + 8e8276e commit 45570dd

File tree

3 files changed

+32
-12
lines changed

3 files changed

+32
-12
lines changed

composer.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@
1818
"wp-cli/wp-cli": "^2.12"
1919
},
2020
"require-dev": {
21-
"wp-cli/wp-cli-tests": "^4.3.9"
21+
"wp-cli/wp-cli-tests": "^5.0.0"
2222
},
2323
"config": {
2424
"process-timeout": 7200,
2525
"sort-packages": true,
2626
"allow-plugins": {
2727
"dealerdirect/phpcodesniffer-composer-installer": true,
28-
"johnpbloch/wordpress-core-installer": true
28+
"johnpbloch/wordpress-core-installer": true,
29+
"phpstan/extension-installer": true
2930
},
3031
"lock": false
3132
},
@@ -34,12 +35,14 @@
3435
"behat-rerun": "rerun-behat-tests",
3536
"lint": "run-linter-tests",
3637
"phpcs": "run-phpcs-tests",
38+
"phpstan": "run-phpstan-tests",
3739
"phpcbf": "run-phpcbf-cleanup",
3840
"phpunit": "run-php-unit-tests",
3941
"prepare-tests": "install-package-tests",
4042
"test": [
4143
"@lint",
4244
"@phpcs",
45+
"@phpstan",
4346
"@phpunit",
4447
"@behat"
4548
]

phpstan.neon.dist

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
parameters:
2+
level: 9
3+
paths:
4+
- src
5+
- find-command.php
6+
scanDirectories:
7+
- vendor/wp-cli/wp-cli/php
8+
scanFiles:
9+
- vendor/php-stubs/wordpress-stubs/wordpress-stubs.php
10+
treatPhpDocTypesAsCertain: false
11+
ignoreErrors:
12+
- identifier: missingType.parameter
13+
- identifier: missingType.return

src/Find_Command.php

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class Find_Command {
88
/**
99
* Paths we can probably ignore recursion into.
1010
*
11-
* @var array
11+
* @var array<string>
1212
*/
1313
private $ignored_paths = [
1414
// System directories
@@ -94,21 +94,21 @@ class Find_Command {
9494
/**
9595
* Start time for the script.
9696
*
97-
* @var integer
97+
* @var float
9898
*/
99-
private $start_time = false;
99+
private $start_time;
100100

101101
/**
102102
* Resolved alias paths
103103
*
104-
* @var array
104+
* @var array<string, string>
105105
*/
106106
private $resolved_aliases = [];
107107

108108
/**
109109
* Found WordPress installations.
110110
*
111-
* @var array
111+
* @var array<string, array<string, mixed>>
112112
*/
113113
private $found_wp = [];
114114

@@ -190,7 +190,7 @@ class Find_Command {
190190
*/
191191
public function __invoke( $args, $assoc_args ) {
192192
list( $path ) = $args;
193-
$this->base_path = realpath( $path );
193+
$this->base_path = (string) realpath( $path );
194194
if ( ! $this->base_path ) {
195195
WP_CLI::error( 'Invalid path specified.' );
196196
}
@@ -235,7 +235,7 @@ private function recurse_directory( $path ) {
235235
// Don't recurse directories that probably don't have a WordPress installation.
236236
if ( ! $this->skip_ignored_paths ) {
237237
// Assume base path doesn't need comparison
238-
$compared_path = preg_replace( '#^' . preg_quote( $this->base_path, '#' ) . '#', '', $path );
238+
$compared_path = (string) preg_replace( '#^' . preg_quote( $this->base_path, '#' ) . '#', '', $path );
239239
// Ignore all hidden system directories
240240
$bits = explode( '/', trim( $compared_path, '/' ) );
241241
$current_dir = array_pop( $bits );
@@ -276,7 +276,7 @@ private function recurse_directory( $path ) {
276276
try {
277277
$transformer = new WPConfigTransformer( $config_path );
278278
foreach ( [ 'db_host', 'db_name', 'db_user' ] as $constant ) {
279-
$value = $transformer->get_value( 'constant', strtoupper( $constant ) );
279+
$value = (string) $transformer->get_value( 'constant', strtoupper( $constant ) );
280280
// Clean up strings.
281281
$first = substr( $value, 0, 1 );
282282
$last = substr( $value, -1 );
@@ -309,6 +309,10 @@ private function recurse_directory( $path ) {
309309
return;
310310
}
311311
$this->log( "Recursing into '{$path}'" );
312+
313+
/**
314+
* @var SplFileInfo $file_info
315+
*/
312316
foreach ( $iterator as $file_info ) {
313317
if ( $file_info->isDir() ) {
314318
++$this->current_depth;
@@ -322,7 +326,7 @@ private function recurse_directory( $path ) {
322326
* Get the WordPress version for the installation, without executing the file.
323327
*/
324328
private static function get_wp_version( $path ) {
325-
$contents = file_get_contents( $path );
329+
$contents = (string) file_get_contents( $path );
326330
preg_match( '#\$wp_version\s?=\s?[\'"]([^\'"]+)[\'"]#', $contents, $matches );
327331
return ! empty( $matches[1] ) ? $matches[1] : '';
328332
}
@@ -359,7 +363,7 @@ private function log( $message ) {
359363
/**
360364
* Format a log timestamp into something human-readable.
361365
*
362-
* @param integer $s Log time in seconds
366+
* @param int|float $s Log time in seconds
363367
* @return string
364368
*/
365369
private static function format_log_timestamp( $s ) {

0 commit comments

Comments
 (0)