Skip to content

Commit

Permalink
Merge pull request #501 from FriendsOfSymfony/github-phpstan
Browse files Browse the repository at this point in the history
phpstan static analysis with github workflow
  • Loading branch information
dbu committed Jul 7, 2021
2 parents cbc3f7d + f25a9af commit 853028c
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 15 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[*.yml]
indent_size = 2
46 changes: 46 additions & 0 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Static analysis

on:
push:
branches:
- master
pull_request:

jobs:
phpstan:
name: PHPStan src
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Pull in optional dependencies
run: |
composer require --no-update symfony/http-kernel symfony/event-dispatcher symfony/process phpunit/phpunit psr/log toflar/psr6-symfony-http-cache-store
composer update --no-dev --no-progress
- name: PHPStan
uses: docker://oskarstark/phpstan-ga
with:
args: analyze --no-progress

phpstan-tests:
name: PHPStan tests
runs-on: ubuntu-latest
env:
REQUIRE_DEV: "true"

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Pull in optional dependencies
run: |
composer require --no-update phpunit/phpunit toflar/psr6-symfony-http-cache-store
composer update --no-progress
- name: PHPStan
uses: docker://oskarstark/phpstan-ga
with:
args: analyze --no-progress -c phpstan.tests.neon.dist
11 changes: 11 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
parameters:
level: 1
paths:
- src
excludePaths:
analyseAndScan:
# contains code to support legacy phpunit versions
# TODO: clean up the code in this namespace and support fewer phpunit versions
- src/Test/*
# contains BC code to support Symfony 3.4 that would not work with never versions
- src/BaseEvent.php
4 changes: 4 additions & 0 deletions phpstan.tests.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
parameters:
level: 1
paths:
- tests
7 changes: 3 additions & 4 deletions src/ProxyClient/Fastly.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
use FOS\HttpCache\ProxyClient\Invalidation\PurgeCapable;
use FOS\HttpCache\ProxyClient\Invalidation\RefreshCapable;
use FOS\HttpCache\ProxyClient\Invalidation\TagCapable;
use Symfony\Component\HttpFoundation\Request;

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

// Secondly make sure refresh is triggered with a HEAD request
$this->queueRequest(
Request::METHOD_HEAD,
'HEAD',
$url,
$headers,
false
Expand All @@ -137,7 +136,7 @@ public function refresh($url, array $headers = [])
public function clear()
{
$this->queueRequest(
Request::METHOD_POST,
'POST',
sprintf(self::API_ENDPOINT.'/service/%s/purge_all', $this->options['service_identifier']),
['Accept' => 'application/json'],
false
Expand Down
12 changes: 1 addition & 11 deletions src/Test/Proxy/AbstractProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace FOS\HttpCache\Test\Proxy;

use Symfony\Component\Process\Process;
use Symfony\Component\Process\ProcessBuilder;

abstract class AbstractProxy implements ProxyInterface
{
Expand Down Expand Up @@ -100,16 +99,7 @@ protected function wait($timeout, $callback)
*/
protected function runCommand($command, array $arguments)
{
if (method_exists(Process::class, 'setStdin')) {
// Symfony 2, process can not handle an array as command. Use the meanwhile deprecated ProcessBuilder
$builder = new ProcessBuilder($arguments);
$builder->setPrefix($command);

$process = $builder->getProcess();
} else {
$process = new Process(array_merge([$command], $arguments));
}

$process = new Process(array_merge([$command], $arguments));
$process->run();

if (!$process->isSuccessful()) {
Expand Down

0 comments on commit 853028c

Please sign in to comment.