Skip to content

Commit 94597ee

Browse files
committed
Fix some newly reported PHPStan issues
1 parent e0ecaa4 commit 94597ee

7 files changed

Lines changed: 109 additions & 6 deletions

File tree

phpcs.xml.dist

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<exclude-pattern>*/src/WP_CLI/JsonManipulator\.php$</exclude-pattern>
1919
<exclude-pattern>*/src/WP_CLI/Package/Compat/Min_Composer_1_10/NullIOMethodsTrait\.php$</exclude-pattern>
2020
<exclude-pattern>*/src/WP_CLI/Package/Compat/Min_Composer_2_3/NullIOMethodsTrait\.php$</exclude-pattern>
21-
<exclude-pattern>*/tests/JsonManipulatorTest\.php$</exclude-pattern>
21+
<exclude-pattern>*/tests/phpunit/JsonManipulatorTest\.php$</exclude-pattern>
2222

2323
<!-- Show progress. -->
2424
<arg value="p"/>
@@ -63,4 +63,5 @@
6363
<exclude-pattern>*/src/Package_Command\.php$</exclude-pattern>
6464
</rule>
6565

66+
<exclude-pattern>/tests/phpstan/scan-files</exclude-pattern>
6667
</ruleset>

phpstan.neon.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ parameters:
77
- vendor/wp-cli/wp-cli/php
88
scanFiles:
99
- vendor/php-stubs/wordpress-stubs/wordpress-stubs.php
10+
- tests/phpstan/scan-files.php
1011
treatPhpDocTypesAsCertain: false
1112
ignoreErrors:
1213
# WP_CLI_VERSION is defined in wp-cli core at runtime

phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
colors="true"
1414
verbose="true">
1515
<testsuite name="wp-cli/package-command tests">
16-
<directory suffix="Test.php">tests</directory>
16+
<directory suffix="Test.php">tests/phpunit</directory>
1717
</testsuite>
1818

1919
<filter>

src/Package_Command.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -822,8 +822,8 @@ private function package_index() {
822822
* Displays a set of packages
823823
*
824824
* @param string $context
825-
* @param array
826-
* @param array
825+
* @param array $packages
826+
* @param array $assoc_args
827827
*/
828828
private function show_packages( $context, $packages, $assoc_args ) {
829829
$default_fields = [];
@@ -1130,8 +1130,8 @@ private function create_default_composer_json( $composer_path ) {
11301130
*
11311131
* @param PackageInterface $package
11321132
* @param Composer $composer
1133-
* @param string $phpVersion
1134-
* @param bool $minorOnly
1133+
* @param string $php_version
1134+
* @param bool $minor_only
11351135
*
11361136
* @return PackageInterface|null
11371137
*/

tests/phpstan/scan-files.php

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
<?php
2+
3+
namespace {
4+
class Requests_Exception extends WpOrg\Requests\Exception {
5+
}
6+
7+
class Requests_Response extends WpOrg\Requests\Response {
8+
}
9+
}
10+
11+
namespace WpOrg\Requests {
12+
class Exception extends \Exception {
13+
/**
14+
* Like {@see \Exception::getCode()}, but a string code.
15+
*
16+
* @return string
17+
*/
18+
public function getType() {
19+
}
20+
21+
/**
22+
* Gives any relevant data
23+
*
24+
* @return mixed
25+
*/
26+
public function getData() {
27+
}
28+
}
29+
30+
class Response {
31+
/**
32+
* Response body
33+
*
34+
* @var string
35+
*/
36+
public $body = '';
37+
38+
/**
39+
* Raw HTTP data from the transport
40+
*
41+
* @var string
42+
*/
43+
public $raw = '';
44+
45+
/**
46+
* Headers, as an associative array
47+
*
48+
* @var \WpOrg\Requests\Response\Headers Array-like object representing headers
49+
*/
50+
public $headers = [];
51+
52+
/**
53+
* Status code, false if non-blocking
54+
*
55+
* @var integer|boolean
56+
*/
57+
public $status_code = false;
58+
59+
/**
60+
* Protocol version, false if non-blocking
61+
*
62+
* @var float|boolean
63+
*/
64+
public $protocol_version = false;
65+
66+
/**
67+
* Whether the request succeeded or not
68+
*
69+
* @var boolean
70+
*/
71+
public $success = false;
72+
73+
/**
74+
* Number of redirects the request used
75+
*
76+
* @var integer
77+
*/
78+
public $redirects = 0;
79+
80+
/**
81+
* URL requested
82+
*
83+
* @var string
84+
*/
85+
public $url = '';
86+
87+
/**
88+
* Previous requests (from redirects)
89+
*
90+
* @var array Array of \WpOrg\Requests\Response objects
91+
*/
92+
public $history = [];
93+
94+
/**
95+
* Cookies from the request
96+
*
97+
* @var array Array-like object representing a cookie jar
98+
*/
99+
public $cookies = [];
100+
}
101+
}

0 commit comments

Comments
 (0)