Skip to content

Commit 853028c

Browse files
authored
Merge pull request #501 from FriendsOfSymfony/github-phpstan
phpstan static analysis with github workflow
2 parents cbc3f7d + f25a9af commit 853028c

File tree

6 files changed

+67
-15
lines changed

6 files changed

+67
-15
lines changed

Diff for: .github/workflows/.editorconfig

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[*.yml]
2+
indent_size = 2

Diff for: .github/workflows/static.yml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Static analysis
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
jobs:
10+
phpstan:
11+
name: PHPStan src
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v2
17+
18+
- name: Pull in optional dependencies
19+
run: |
20+
composer require --no-update symfony/http-kernel symfony/event-dispatcher symfony/process phpunit/phpunit psr/log toflar/psr6-symfony-http-cache-store
21+
composer update --no-dev --no-progress
22+
23+
- name: PHPStan
24+
uses: docker://oskarstark/phpstan-ga
25+
with:
26+
args: analyze --no-progress
27+
28+
phpstan-tests:
29+
name: PHPStan tests
30+
runs-on: ubuntu-latest
31+
env:
32+
REQUIRE_DEV: "true"
33+
34+
steps:
35+
- name: Checkout code
36+
uses: actions/checkout@v2
37+
38+
- name: Pull in optional dependencies
39+
run: |
40+
composer require --no-update phpunit/phpunit toflar/psr6-symfony-http-cache-store
41+
composer update --no-progress
42+
43+
- name: PHPStan
44+
uses: docker://oskarstark/phpstan-ga
45+
with:
46+
args: analyze --no-progress -c phpstan.tests.neon.dist

Diff for: phpstan.neon.dist

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
parameters:
2+
level: 1
3+
paths:
4+
- src
5+
excludePaths:
6+
analyseAndScan:
7+
# contains code to support legacy phpunit versions
8+
# TODO: clean up the code in this namespace and support fewer phpunit versions
9+
- src/Test/*
10+
# contains BC code to support Symfony 3.4 that would not work with never versions
11+
- src/BaseEvent.php

Diff for: phpstan.tests.neon.dist

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
parameters:
2+
level: 1
3+
paths:
4+
- tests

Diff for: src/ProxyClient/Fastly.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use FOS\HttpCache\ProxyClient\Invalidation\PurgeCapable;
1616
use FOS\HttpCache\ProxyClient\Invalidation\RefreshCapable;
1717
use FOS\HttpCache\ProxyClient\Invalidation\TagCapable;
18-
use Symfony\Component\HttpFoundation\Request;
1918

2019
/**
2120
* Fastly HTTP cache invalidator.
@@ -68,7 +67,7 @@ public function invalidateTags(array $tags)
6867
// Split tag invalidations across several requests within Fastly's tag batch invalidations limits.
6968
foreach (\array_chunk($tags, self::TAG_BATCH_PURGE_LIMIT) as $tagChunk) {
7069
$this->queueRequest(
71-
Request::METHOD_POST,
70+
'POST',
7271
$url,
7372
$headers,
7473
false,
@@ -116,7 +115,7 @@ public function refresh($url, array $headers = [])
116115

117116
// Secondly make sure refresh is triggered with a HEAD request
118117
$this->queueRequest(
119-
Request::METHOD_HEAD,
118+
'HEAD',
120119
$url,
121120
$headers,
122121
false
@@ -137,7 +136,7 @@ public function refresh($url, array $headers = [])
137136
public function clear()
138137
{
139138
$this->queueRequest(
140-
Request::METHOD_POST,
139+
'POST',
141140
sprintf(self::API_ENDPOINT.'/service/%s/purge_all', $this->options['service_identifier']),
142141
['Accept' => 'application/json'],
143142
false

Diff for: src/Test/Proxy/AbstractProxy.php

+1-11
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace FOS\HttpCache\Test\Proxy;
1313

1414
use Symfony\Component\Process\Process;
15-
use Symfony\Component\Process\ProcessBuilder;
1615

1716
abstract class AbstractProxy implements ProxyInterface
1817
{
@@ -100,16 +99,7 @@ protected function wait($timeout, $callback)
10099
*/
101100
protected function runCommand($command, array $arguments)
102101
{
103-
if (method_exists(Process::class, 'setStdin')) {
104-
// Symfony 2, process can not handle an array as command. Use the meanwhile deprecated ProcessBuilder
105-
$builder = new ProcessBuilder($arguments);
106-
$builder->setPrefix($command);
107-
108-
$process = $builder->getProcess();
109-
} else {
110-
$process = new Process(array_merge([$command], $arguments));
111-
}
112-
102+
$process = new Process(array_merge([$command], $arguments));
113103
$process->run();
114104

115105
if (!$process->isSuccessful()) {

0 commit comments

Comments
 (0)