Skip to content

Commit 734a76e

Browse files
authored
Introduce Phpstan (#456)
1 parent 78a66e0 commit 734a76e

File tree

7 files changed

+78
-15
lines changed

7 files changed

+78
-15
lines changed
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: "Static analysis"
2+
3+
on:
4+
push:
5+
branches:
6+
- '[0-9]+.x'
7+
- '[0-9]+.[0-9]+'
8+
- '[0-9]+.[0-9]+.x'
9+
pull_request:
10+
11+
jobs:
12+
phpstan:
13+
name: "PHPStan"
14+
runs-on: "ubuntu-latest"
15+
16+
steps:
17+
- name: "Checkout"
18+
uses: "actions/checkout@v3"
19+
- name: PHPStan
20+
uses: "docker://oskarstark/phpstan-ga"
21+
env:
22+
REQUIRE_DEV: true
23+
with:
24+
args: analyze --no-progress

.github/workflows/static-analysis.yml renamed to .github/workflows/php-cs-fixer.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: "Static analysis"
1+
name: "PHP-CS-Fixer"
22

33
on:
44
push:
@@ -9,8 +9,8 @@ on:
99
pull_request:
1010

1111
jobs:
12-
coding-standards:
13-
name: "Coding Standards"
12+
php-cs-fixer:
13+
name: "PHP-CS-Fixer"
1414
runs-on: "ubuntu-latest"
1515

1616
steps:

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
/build/
55
/composer.lock
66
/phpspec.yml
7+
/phpstan.neon
78
/phpunit.xml
89
/vendor/

composer.json

+3-7
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,11 @@
4343
},
4444
"conflict": {
4545
"php-http/guzzle6-adapter": "<1.1",
46-
"php-http/cache-plugin": "<1.7.0",
46+
"php-http/cache-plugin": "<1.7",
4747
"php-http/curl-client": "<2.0",
4848
"php-http/socket-client": "<2.0",
4949
"kriswallsmith/buzz": "<0.17",
50-
"php-http/react-adapter": "<3.0",
51-
"php-http/cache-plugin": "<1.7"
50+
"php-http/react-adapter": "<3.0"
5251
},
5352
"require-dev": {
5453
"guzzlehttp/psr7": "^1.7 || ^2.0",
@@ -84,10 +83,7 @@
8483
"autoload": {
8584
"psr-4": {
8685
"Http\\HttplugBundle\\": "src/"
87-
},
88-
"exclude-from-classmap": [
89-
"/Tests/Resources/MyPsr18TestClient.php"
90-
]
86+
}
9187
},
9288
"autoload-dev": {
9389
"psr-4": {

phpstan-baseline.neon

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
parameters:
2+
ignoreErrors:
3+
-
4+
message: "#^Call to static method create\\(\\) on an unknown class Symfony\\\\Component\\\\HttpClient\\\\HttpClient\\.$#"
5+
count: 1
6+
path: src/ClientFactory/SymfonyFactory.php
7+
8+
-
9+
message: "#^Class Http\\\\Client\\\\Plugin\\\\Vcr\\\\NamingStrategy\\\\NamingStrategyInterface not found\\.$#"
10+
count: 1
11+
path: src/DependencyInjection/Configuration.php
12+
13+
-
14+
message: "#^Class Http\\\\Client\\\\Plugin\\\\Vcr\\\\Recorder\\\\PlayerInterface not found\\.$#"
15+
count: 1
16+
path: src/DependencyInjection/Configuration.php
17+
18+
-
19+
message: "#^Class Http\\\\Client\\\\Plugin\\\\Vcr\\\\Recorder\\\\RecorderInterface not found\\.$#"
20+
count: 1
21+
path: src/DependencyInjection/Configuration.php
22+
23+
-
24+
message: "#^Class Http\\\\Client\\\\Plugin\\\\Vcr\\\\RecordPlugin not found\\.$#"
25+
count: 1
26+
path: src/DependencyInjection/HttplugExtension.php
27+
28+
-
29+
message: "#^Class Http\\\\Client\\\\Plugin\\\\Vcr\\\\ReplayPlugin not found\\.$#"
30+
count: 1
31+
path: src/DependencyInjection/HttplugExtension.php

phpstan.neon.dist

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
includes:
2+
- phpstan-baseline.neon
3+
- %rootDir%/../phpstan-symfony/extension.neon
4+
- %rootDir%/../phpstan-symfony/rules.neon
5+
6+
parameters:
7+
scanFiles:
8+
- vendor/symfony/dependency-injection/Loader/Configurator/ContainerConfigurator.php
9+
10+
level: 2
11+
paths:
12+
- src

src/Collector/PluginClientFactory.php

+4-5
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,10 @@ public function __construct(Collector $collector, Formatter $formatter, Stopwatc
4545
/**
4646
* @param ClientInterface|HttpAsyncClient $client
4747
* @param Plugin[] $plugins
48-
* @param array $options {
48+
* @param array{client_name?: string} $options
4949
*
50-
* @var string $client_name to give client a name which may be used when displaying client information like in
51-
* the HTTPlugBundle profiler.
52-
* }
50+
* - client_name: to give client a name which may be used when displaying client information like in
51+
* the HTTPlugBundle profiler
5352
*
5453
* @see PluginClient constructor for PluginClient specific $options.
5554
*
@@ -61,7 +60,7 @@ public function createClient($client, array $plugins = [], array $options = [])
6160
return new ProfilePlugin($plugin, $this->collector, $this->formatter);
6261
}, $plugins);
6362

64-
$clientName = isset($options['client_name']) ? $options['client_name'] : 'Default';
63+
$clientName = $options['client_name'] ?? 'Default';
6564
array_unshift($plugins, new StackPlugin($this->collector, $this->formatter, $clientName));
6665
unset($options['client_name']);
6766

0 commit comments

Comments
 (0)