Skip to content

Commit 98737de

Browse files
committed
adjust for symfony 7
1 parent 0761a0b commit 98737de

15 files changed

+122
-210
lines changed

.github/workflows/ci.yml

Lines changed: 11 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,8 @@ jobs:
2222
matrix:
2323
varnish-version: ['6.6']
2424
varnish-modules-version: ['0.18.0']
25-
php: ['7.3', '7.4', '8.0', '8.1']
25+
php: ['8.1', '8.2', '8.3']
2626
include:
27-
- php: '7.4'
28-
symfony-version: '4.3.*'
29-
- php: '7.4'
30-
symfony-version: '5.0.*'
3127
- php: '8.1'
3228
symfony-version: '6.*'
3329
- php: '8.1'
@@ -66,42 +62,9 @@ jobs:
6662
run: |
6763
composer require --no-update ${DEPENDENCIES}
6864
composer update --prefer-dist --no-interaction --no-progress
69-
vendor/bin/simple-phpunit install
7065
7166
- name: Execute tests
72-
run: vendor/bin/simple-phpunit -v
73-
74-
legacyPHP:
75-
name: PHP 7.2 Varnish 6
76-
runs-on: ubuntu-20.04
77-
env:
78-
VARNISH_VERSION: '6.6'
79-
VARNISH_MODULES_VERSION: '0.18.0'
80-
81-
steps:
82-
- name: Setup PHP
83-
uses: shivammathur/setup-php@v2
84-
with:
85-
php-version: 7.2
86-
tools: composer:v2
87-
coverage: none
88-
89-
- name: Checkout code
90-
uses: actions/checkout@v2
91-
92-
- name: Setup Varnish and Nginx
93-
run: |
94-
sh ${GITHUB_WORKSPACE}/.github/workflows/setup-varnish.sh
95-
sh ${GITHUB_WORKSPACE}/.github/workflows/setup-nginx.sh
96-
97-
- name: Install composer dependencies
98-
run: |
99-
composer require --no-update ${DEPENDENCIES}
100-
composer update --prefer-dist --no-interaction --no-progress
101-
vendor/bin/simple-phpunit install
102-
103-
- name: Execute tests
104-
run: vendor/bin/simple-phpunit -v
67+
run: vendor/bin/phpunit
10568

10669
varnish5:
10770
name: PHP ${{ matrix.php }} Legacy Varnish 5
@@ -114,7 +77,7 @@ jobs:
11477
fail-fast: false
11578
matrix:
11679
include:
117-
- php: '7.4'
80+
- php: '8.1'
11881

11982
steps:
12083
- name: Setup PHP
@@ -135,10 +98,9 @@ jobs:
13598
- name: Install composer dependencies
13699
run: |
137100
composer update --prefer-dist --prefer-stable --prefer-lowest --no-interaction --no-progress
138-
vendor/bin/simple-phpunit install
139101
140102
- name: Execute tests
141-
run: vendor/bin/simple-phpunit -v
103+
run: vendor/bin/phpunit
142104

143105
varnish4:
144106
name: PHP ${{ matrix.php }} Legacy Varnish 4
@@ -151,7 +113,7 @@ jobs:
151113
fail-fast: false
152114
matrix:
153115
include:
154-
- php: '7.4'
116+
- php: '8.1'
155117

156118
steps:
157119
- name: Setup PHP
@@ -172,10 +134,9 @@ jobs:
172134
- name: Install composer dependencies
173135
run: |
174136
composer update --prefer-dist --prefer-stable --prefer-lowest --no-interaction --no-progress
175-
vendor/bin/simple-phpunit install
176137
177138
- name: Execute tests
178-
run: vendor/bin/simple-phpunit -v
139+
run: vendor/bin/phpunit
179140

180141
lowest:
181142
name: PHP ${{ matrix.php }} Lowest, Varnish 3
@@ -188,7 +149,7 @@ jobs:
188149
strategy:
189150
fail-fast: false
190151
matrix:
191-
php: ['7.2']
152+
php: ['8.1']
192153

193154
steps:
194155
- name: Setup PHP
@@ -209,10 +170,9 @@ jobs:
209170
- name: Install composer dependencies
210171
run: |
211172
composer update --prefer-dist --prefer-stable --prefer-lowest --no-interaction --no-progress
212-
vendor/bin/simple-phpunit install
213173
214174
- name: Execute tests
215-
run: vendor/bin/simple-phpunit -v
175+
run: vendor/bin/phpunit
216176

217177
coverage:
218178
name: Code Coverage
@@ -225,7 +185,7 @@ jobs:
225185
- name: Setup PHP
226186
uses: shivammathur/setup-php@v2
227187
with:
228-
php-version: 7.4
188+
php-version: 8.2
229189
tools: composer:v2
230190
coverage: xdebug
231191

@@ -239,14 +199,8 @@ jobs:
239199
240200
- name: Install dependencies
241201
run: |
242-
composer require "friends-of-phpspec/phpspec-code-coverage:^4.3.2" --no-interaction --no-update
202+
composer require "friends-of-phpspec/phpspec-code-coverage:^6.3.0" --no-interaction --no-update
243203
composer update --prefer-dist --no-interaction --no-progress
244-
vendor/bin/simple-phpunit install
245204
246205
- name: Execute tests
247-
run: vendor/bin/simple-phpunit -v --coverage-text --coverage-clover build/coverage.xml
248-
249-
- name: Upload coverage
250-
run: |
251-
wget https://scrutinizer-ci.com/ocular.phar
252-
php ocular.phar code-coverage:upload --format=php-clover build/coverage.xml --revision=${{ github.event.pull_request.head.sha || github.sha }}
206+
run: vendor/bin/phpunit --coverage-text --coverage-clover build/coverage.xml

.github/workflows/static.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,13 @@ jobs:
1010
phpstan-src:
1111
name: PHPStan src
1212
runs-on: ubuntu-latest
13-
env:
14-
REQUIRE_DEV: "true"
1513

1614
steps:
1715
- name: Checkout code
1816
uses: actions/checkout@v2
1917

2018
- name: Pull in optional dependencies
21-
run: composer require --no-update phpunit/phpunit toflar/psr6-symfony-http-cache-store:^3.0
19+
run: composer require --no-update phpunit/phpunit toflar/psr6-symfony-http-cache-store:^4.2
2220

2321
- name: PHPStan
2422
uses: docker://oskarstark/phpstan-ga
@@ -36,7 +34,7 @@ jobs:
3634
uses: actions/checkout@v2
3735

3836
- name: Pull in optional dependencies
39-
run: composer require --no-update phpunit/phpunit toflar/psr6-symfony-http-cache-store:^3.0
37+
run: composer require --no-update phpunit/phpunit toflar/psr6-symfony-http-cache-store:^4.2
4038

4139
- name: PHPStan
4240
uses: docker://oskarstark/phpstan-ga

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,21 @@ Changelog
33

44
See also the [GitHub releases page](https://github.com/FriendsOfSymfony/FOSHttpCache/releases).
55

6+
3.x
7+
===
8+
9+
3.0.0 (unreleased)
10+
-----
11+
12+
* Support Symfony 7
13+
* Drop support for Symfony < 6.4
14+
* Test with PHP 8.2 and 8.3
15+
* Drop support for PHP < 8.1
16+
* Parameter and return type declarations where possible.
17+
18+
2.x
19+
===
20+
621
2.15.3
722
------
823

composer.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,23 @@
2121
}
2222
],
2323
"require": {
24-
"php": "^7.2 || ^8.0",
25-
"symfony/event-dispatcher": "^4.3 || ^5.0 || ^6.0 || ^7.0",
26-
"symfony/options-resolver": "^4.3 || ^5.0 || ^6.0 || ^7.0",
24+
"php": "^8.1",
25+
"symfony/event-dispatcher": "^6.4 || ^7.0",
26+
"symfony/options-resolver": "^6.4 || ^7.0",
2727
"php-http/client-implementation": "^1.0 || ^2.0",
2828
"php-http/client-common": "^1.1.0 || ^2.0",
2929
"php-http/message": "^1.0 || ^2.0",
3030
"php-http/message-factory": "^1.0",
3131
"php-http/discovery": "^1.12"
3232
},
3333
"require-dev": {
34-
"mockery/mockery": "^1.3.1",
34+
"mockery/mockery": "^1.6.0",
3535
"monolog/monolog": "^1.0",
3636
"php-http/guzzle7-adapter": "^0.1.1",
37-
"php-http/mock-client": "^1.2",
38-
"symfony/process": "^4.3 || ^5.0 || ^6.0|| ^7.0",
39-
"symfony/http-kernel": "^4.3 || ^5.0 || ^6.0|| ^7.0",
40-
"symfony/phpunit-bridge": "^5.0 || ^6.0|| ^7.0"
37+
"php-http/mock-client": "^1.6.0",
38+
"symfony/process": "^6.4|| ^7.0",
39+
"symfony/http-kernel": "^6.4|| ^7.0",
40+
"phpunit/phpunit": "^9"
4141
},
4242
"conflict": {
4343
"toflar/psr6-symfony-http-cache-store": "<2.2.1"

src/SymfonyCache/AccessControlledListener.php

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
1515
use Symfony\Component\HttpFoundation\Request;
16-
use Symfony\Component\HttpFoundation\RequestMatcher;
1716
use Symfony\Component\HttpFoundation\RequestMatcher\IpsRequestMatcher;
1817
use Symfony\Component\HttpFoundation\RequestMatcherInterface;
1918
use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -26,10 +25,7 @@
2625
*/
2726
abstract class AccessControlledListener implements EventSubscriberInterface
2827
{
29-
/**
30-
* @var RequestMatcherInterface
31-
*/
32-
private $clientMatcher;
28+
private RequestMatcherInterface $clientMatcher;
3329

3430
/**
3531
* When creating this event listener, you can configure a number of options.
@@ -38,7 +34,7 @@ abstract class AccessControlledListener implements EventSubscriberInterface
3834
* - client_ips: IP or array of IPs of clients that are allowed to send requests.
3935
*
4036
* Only one of request matcher or IPs may be a non-null value. If you use a
41-
* RequestMatcher, configure your IPs into it.
37+
* RequestMatcherInterface, include an IpsRequestMatcher with your IPs.
4238
*
4339
* If neither parameter is set, the filter is IP 127.0.0.1
4440
*
@@ -55,10 +51,7 @@ public function __construct(array $options = [])
5551
throw new \InvalidArgumentException('You may not set both a request matcher and an IP.');
5652
}
5753
if (!$clientMatcher) {
58-
$clientMatcher = class_exists(IpsRequestMatcher::class)
59-
? new IpsRequestMatcher($options['client_ips'] ?: '127.0.0.1')
60-
: new RequestMatcher(null, null, null, $options['client_ips'] ?: '127.0.0.1')
61-
;
54+
$clientMatcher = new IpsRequestMatcher($options['client_ips'] ?: '127.0.0.1');
6255
}
6356

6457
$this->clientMatcher = $clientMatcher;

src/SymfonyCache/CacheEvent.php

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -23,35 +23,23 @@
2323
*/
2424
class CacheEvent extends BaseEvent
2525
{
26-
/**
27-
* @var CacheInvalidation
28-
*/
29-
private $kernel;
26+
private CacheInvalidation $kernel;
3027

31-
/**
32-
* @var Request
33-
*/
34-
private $request;
28+
private Request $request;
3529

36-
/**
37-
* @var Response
38-
*/
39-
private $response;
30+
private ?Response $response;
4031

41-
/**
42-
* @var int
43-
*/
44-
private $requestType;
32+
private int $requestType;
4533

4634
/**
4735
* Make sure your $kernel implements CacheInvalidationInterface.
4836
*
4937
* @param CacheInvalidation $kernel the kernel raising with this event
5038
* @param Request $request the request being processed
5139
* @param Response|null $response the response, if available
52-
* @param int $requestType the request type (default HttpKernelInterface::MASTER_REQUEST)
40+
* @param int $requestType the request type (default HttpKernelInterface::MAIN_REQUEST)
5341
*/
54-
public function __construct(CacheInvalidation $kernel, Request $request, Response $response = null, $requestType = HttpKernelInterface::MASTER_REQUEST)
42+
public function __construct(CacheInvalidation $kernel, Request $request, Response $response = null, int $requestType = HttpKernelInterface::MAIN_REQUEST)
5543
{
5644
$this->kernel = $kernel;
5745
$this->request = $request;
@@ -71,31 +59,25 @@ public function getKernel()
7159

7260
/**
7361
* Get the request that is being processed.
74-
*
75-
* @return Request
7662
*/
77-
public function getRequest()
63+
public function getRequest(): Request
7864
{
7965
return $this->request;
8066
}
8167

8268
/**
83-
* One of the constants HttpKernelInterface::MASTER_REQUEST or SUB_REQUEST.
84-
*
85-
* @return int
69+
* One of the constants HttpKernelInterface::MAIN_REQUEST or SUB_REQUEST.
8670
*/
87-
public function getRequestType()
71+
public function getRequestType(): int
8872
{
8973
return $this->requestType;
9074
}
9175

9276
/**
9377
* Events that occur after the response is created provide the default response.
9478
* Event listeners can also set the response to make it available here.
95-
*
96-
* @return Response|null the response if one was set
9779
*/
98-
public function getResponse()
80+
public function getResponse(): ?Response
9981
{
10082
return $this->response;
10183
}
@@ -105,7 +87,7 @@ public function getResponse()
10587
*
10688
* Setting a response stops propagation of the event to further event handlers.
10789
*/
108-
public function setResponse(Response $response)
90+
public function setResponse(Response $response): void
10991
{
11092
$this->response = $response;
11193

0 commit comments

Comments
 (0)