-
Notifications
You must be signed in to change notification settings - Fork 53
Static analysis fixes #203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
3c5dd1a
aa79242
f62596a
09979e6
07ce778
8151f0f
8e4b661
dd7952e
5ea39f2
6ed68c4
3807750
0c0f1be
9b7938f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
.editorconfig export-ignore | ||
.gitattributes export-ignore | ||
/.github/ export-ignore | ||
.gitignore export-ignore | ||
/.php_cs export-ignore | ||
/.scrutinizer.yml export-ignore | ||
/.styleci.yml export-ignore | ||
/behat.yml.dist export-ignore | ||
/features/ export-ignore | ||
/phpspec.ci.yml export-ignore | ||
/phpspec.yml.dist export-ignore | ||
/phpunit.xml.dist export-ignore | ||
/spec/ export-ignore | ||
/tests/ export-ignore | ||
.editorconfig export-ignore | ||
.gitattributes export-ignore | ||
/.github/ export-ignore | ||
.gitignore export-ignore | ||
/.php_cs export-ignore | ||
/.scrutinizer.yml export-ignore | ||
/.styleci.yml export-ignore | ||
/behat.yml.dist export-ignore | ||
/features/ export-ignore | ||
/phpspec.ci.yml export-ignore | ||
/phpspec.yml.dist export-ignore | ||
/phpunit.xml.dist export-ignore | ||
/phpstan.neon.dist export-ignore | ||
/spec/ export-ignore | ||
/tests/ export-ignore |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: static | ||
|
||
on: | ||
push: | ||
pull_request: | ||
|
||
jobs: | ||
phpstan: | ||
name: PHPStan | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: PHPStan | ||
uses: OskarStark/[email protected] | ||
env: | ||
REQUIRE_DEV: false | ||
with: | ||
args: analyze --no-progress |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,5 @@ | |
/composer.lock | ||
/phpspec.yml | ||
/phpunit.xml | ||
/phpstan.neon | ||
/vendor/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
parameters: | ||
level: max | ||
checkMissingIterableValueType: false | ||
treatPhpDocTypesAsCertain: false | ||
paths: | ||
- src | ||
ignoreErrors: | ||
- | ||
message: "#^Strict comparison using \\!\\=\\= between null and null will always evaluate to false\\.$#" | ||
count: 1 | ||
path: src/HttpMethodsClient.php | ||
|
||
- | ||
message: "#^Cannot call method createStream\\(\\) on Psr\\\\Http\\\\Message\\\\StreamFactoryInterface\\|null\\.$#" | ||
count: 1 | ||
path: src/HttpMethodsClient.php | ||
|
||
- | ||
message: "#^Method Http\\\\Client\\\\Common\\\\Plugin\\\\Journal\\:\\:addSuccess\\(\\) has no return typehint specified\\.$#" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a no-fix. Changing it would break BC. Maybe we should consider adding void return to the interface in the next major version. |
||
count: 1 | ||
path: src/Plugin/Journal.php | ||
|
||
- | ||
message: "#^Method Http\\\\Client\\\\Common\\\\Plugin\\\\Journal\\:\\:addFailure\\(\\) has no return typehint specified\\.$#" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a no-fix. Changing it would break BC. Maybe we should consider adding void return to the interface in the next major version. |
||
count: 1 | ||
path: src/Plugin/Journal.php | ||
|
||
- | ||
message: "#^Call to an undefined method Http\\\\Client\\\\HttpAsyncClient\\:\\:sendRequest\\(\\)\\.$#" | ||
count: 1 | ||
path: src/PluginClient.php |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,13 +25,14 @@ abstract class HttpClientPool implements HttpClientPoolInterface | |
/** | ||
* Add a client to the pool. | ||
* | ||
* @param ClientInterface|HttpAsyncClient|HttpClientPoolItem $client | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not a BC break. A |
||
* @param ClientInterface|HttpAsyncClient $client | ||
*/ | ||
public function addHttpClient($client): void | ||
{ | ||
if (!$client instanceof ClientInterface && !$client instanceof HttpAsyncClient && !$client instanceof HttpClientPoolItem) { | ||
// no need to check for HttpClientPoolItem here, since it extends the other interfaces | ||
if (!$client instanceof ClientInterface && !$client instanceof HttpAsyncClient) { | ||
throw new \TypeError( | ||
sprintf('%s::addHttpClient(): Argument #1 ($client) must be of type %s|%s|%s, %s given', self::class, ClientInterface::class, HttpAsyncClient::class, HttpClientPoolItem::class, get_debug_type($client)) | ||
sprintf('%s::addHttpClient(): Argument #1 ($client) must be of type %s|%s, %s given', self::class, ClientInterface::class, HttpAsyncClient::class, get_debug_type($client)) | ||
); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -117,7 +117,7 @@ private function createCookie(RequestInterface $request, string $setCookieHeader | |
switch (strtolower($key)) { | ||
case 'expires': | ||
try { | ||
$expires = CookieUtil::parseDate($value); | ||
$expires = CookieUtil::parseDate((string) $value); | ||
} catch (UnexpectedValueException $e) { | ||
throw new TransferException( | ||
sprintf( | ||
|
@@ -167,13 +167,13 @@ private function createCookie(RequestInterface $request, string $setCookieHeader | |
* | ||
* @param string $part A single cookie value in format key=value | ||
* | ||
* @return string[] | ||
* @return array{0:string, 1:?string} | ||
*/ | ||
private function createValueKey(string $part): array | ||
{ | ||
$parts = explode('=', $part, 2); | ||
$key = trim($parts[0]); | ||
$value = isset($parts[1]) ? trim($parts[1]) : true; | ||
$value = isset($parts[1]) ? trim($parts[1]) : null; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not a BC break: the Cookie class only accepts string or null as a value. This is a bug fix. |
||
|
||
return [$key, $value]; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ | |
final class PluginClientFactory | ||
{ | ||
/** | ||
* @var callable|null | ||
* @var (callable(ClientInterface|HttpAsyncClient, Plugin[], array): PluginClient)|null | ||
*/ | ||
private static $factory; | ||
|
||
|
@@ -28,8 +28,10 @@ final class PluginClientFactory | |
* application execution. | ||
* | ||
* @internal | ||
* | ||
* @param callable(ClientInterface|HttpAsyncClient, Plugin[], array): PluginClient $factory | ||
*/ | ||
public static function setFactory(callable $factory) | ||
public static function setFactory(callable $factory): void | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not a BC break: the class is final. |
||
{ | ||
static::$factory = $factory; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a false positive, and should be reported to phpstan as a bug.