Skip to content

Commit 0ea6844

Browse files
committed
phpstan level 4, merge src and tests phpstan
1 parent 2b8f87e commit 0ea6844

File tree

5 files changed

+47
-45
lines changed

5 files changed

+47
-45
lines changed

Diff for: .github/workflows/static.yml

+1-27
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
uses: actions/checkout@v4
1717

1818
- name: Pull in optional dependencies
19-
run: composer require --no-update phpunit/phpunit toflar/psr6-symfony-http-cache-store:^4.2 symfony/process
19+
run: composer require --no-update phpunit/phpunit toflar/psr6-symfony-http-cache-store:^4.2 symfony/process phpstan/phpstan-mockery
2020

2121
- name: Cache Vendor
2222
id: cache-vendor
@@ -30,32 +30,6 @@ jobs:
3030
with:
3131
args: analyze --no-progress
3232

33-
phpstan-tests:
34-
name: PHPStan tests
35-
runs-on: ubuntu-latest
36-
env:
37-
REQUIRE_DEV: "true"
38-
39-
steps:
40-
- name: Checkout code
41-
uses: actions/checkout@v4
42-
43-
- name: Pull in optional dependencies
44-
run: composer require --no-update phpunit/phpunit toflar/psr6-symfony-http-cache-store:^4.2 phpstan/phpstan-mockery
45-
46-
47-
- name: Cache Vendor
48-
id: cache-vendor
49-
uses: actions/cache@v4
50-
with:
51-
path: vendor
52-
key: ${{ runner.os }}-vendor
53-
54-
- name: PHPStan
55-
uses: docker://oskarstark/phpstan-ga
56-
with:
57-
args: analyze --no-progress -c phpstan.tests.neon.dist
58-
5933
php-cs-fixer:
6034
name: PHP-CS-Fixer
6135
runs-on: ubuntu-latest

Diff for: phpstan.neon.dist

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
parameters:
2-
level: 3
2+
level: 4
33
paths:
44
- src
5+
- tests
56

7+
includes:
8+
- vendor/phpstan/phpstan-mockery/extension.neon

Diff for: phpstan.tests.neon.dist

-4
This file was deleted.

Diff for: src/ProxyClient/Cloudflare.php

+3-13
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public function invalidateTags(array $tags): static
8181
sprintf(self::API_ENDPOINT.'/zones/%s/purge_cache', $this->options['zone_identifier']),
8282
[],
8383
false,
84-
$this->json_encode(['tags' => $tags])
84+
json_encode(['tags' => $tags], JSON_THROW_ON_ERROR | JSON_UNESCAPED_SLASHES)
8585
);
8686

8787
return $this;
@@ -115,7 +115,7 @@ public function clear(): static
115115
sprintf(self::API_ENDPOINT.'/zones/%s/purge_cache', $this->options['zone_identifier']),
116116
['Accept' => 'application/json'],
117117
false,
118-
$this->json_encode(['purge_everything' => true])
118+
json_encode(['purge_everything' => true], JSON_THROW_ON_ERROR | JSON_UNESCAPED_SLASHES)
119119
);
120120

121121
return $this;
@@ -130,7 +130,7 @@ public function flush(): int
130130
sprintf(self::API_ENDPOINT.'/zones/%s/purge_cache', $this->options['zone_identifier']),
131131
[],
132132
false,
133-
$this->json_encode(['files' => $urlChunk])
133+
json_encode(['files' => $urlChunk], JSON_THROW_ON_ERROR | JSON_UNESCAPED_SLASHES)
134134
);
135135
}
136136
$this->purgeByUrlsData = [];
@@ -165,14 +165,4 @@ protected function configureOptions(): OptionsResolver
165165

166166
return $resolver;
167167
}
168-
169-
private function json_encode(array $data): string
170-
{
171-
$json = json_encode($data, JSON_THROW_ON_ERROR | JSON_UNESCAPED_SLASHES);
172-
if (false === $json) {
173-
throw new \InvalidArgumentException(sprintf('Cannot encode "$data": %s', json_last_error_msg()));
174-
}
175-
176-
return $json;
177-
}
178168
}

Diff for: tests/Unit/SymfonyCache/CacheAwareTest.php

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the FOSHttpCache package.
5+
*
6+
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace FOS\HttpCache\Tests\Unit\SymfonyCache;
13+
14+
use FOS\HttpCache\SymfonyCache\HttpCacheAware;
15+
use FOS\HttpCache\SymfonyCache\HttpCacheProvider;
16+
use PHPUnit\Framework\TestCase;
17+
use Symfony\Component\HttpKernel\HttpKernelInterface;
18+
19+
class CacheAwareTest extends TestCase
20+
{
21+
private HttpKernelInterface $cacheKernel;
22+
23+
protected function setUp(): void
24+
{
25+
$this->cacheKernel = $this->createMock(HttpKernelInterface::class);
26+
}
27+
28+
public function testCacheGetterSetter(): void
29+
{
30+
$aware = new AppHttpCacheAware();
31+
$aware->setHttpCache($this->cacheKernel);
32+
$this->assertSame($this->cacheKernel, $aware->getHttpCache());
33+
}
34+
}
35+
36+
class AppHttpCacheAware implements HttpCacheProvider
37+
{
38+
use HttpCacheAware;
39+
}

0 commit comments

Comments
 (0)