Skip to content

Commit 979224d

Browse files
authored
Merge pull request #552 from FriendsOfSymfony/sf-7
Sf 7
2 parents 39f6b35 + 98737de commit 979224d

15 files changed

+132
-210
lines changed

.github/workflows/ci.yml

Lines changed: 21 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,23 @@ 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'
3430
varnish-version: '7.1'
3531
varnish-modules-version: '0.20.0'
32+
- php: '8.2'
33+
symfony-version: '7.*'
34+
- php: '8.2'
35+
varnish-version: '7.1'
36+
varnish-modules-version: '0.20.0'
37+
- php: '8.3'
38+
symfony-version: '7.*'
39+
- php: '8.3'
40+
varnish-version: '7.1'
41+
varnish-modules-version: '0.20.0'
3642

3743
steps:
3844
- name: Setup PHP
@@ -56,42 +62,9 @@ jobs:
5662
run: |
5763
composer require --no-update ${DEPENDENCIES}
5864
composer update --prefer-dist --no-interaction --no-progress
59-
vendor/bin/simple-phpunit install
6065
6166
- name: Execute tests
62-
run: vendor/bin/simple-phpunit -v
63-
64-
legacyPHP:
65-
name: PHP 7.2 Varnish 6
66-
runs-on: ubuntu-20.04
67-
env:
68-
VARNISH_VERSION: '6.6'
69-
VARNISH_MODULES_VERSION: '0.18.0'
70-
71-
steps:
72-
- name: Setup PHP
73-
uses: shivammathur/setup-php@v2
74-
with:
75-
php-version: 7.2
76-
tools: composer:v2
77-
coverage: none
78-
79-
- name: Checkout code
80-
uses: actions/checkout@v2
81-
82-
- name: Setup Varnish and Nginx
83-
run: |
84-
sh ${GITHUB_WORKSPACE}/.github/workflows/setup-varnish.sh
85-
sh ${GITHUB_WORKSPACE}/.github/workflows/setup-nginx.sh
86-
87-
- name: Install composer dependencies
88-
run: |
89-
composer require --no-update ${DEPENDENCIES}
90-
composer update --prefer-dist --no-interaction --no-progress
91-
vendor/bin/simple-phpunit install
92-
93-
- name: Execute tests
94-
run: vendor/bin/simple-phpunit -v
67+
run: vendor/bin/phpunit
9568

9669
varnish5:
9770
name: PHP ${{ matrix.php }} Legacy Varnish 5
@@ -104,7 +77,7 @@ jobs:
10477
fail-fast: false
10578
matrix:
10679
include:
107-
- php: '7.4'
80+
- php: '8.1'
10881

10982
steps:
11083
- name: Setup PHP
@@ -125,10 +98,9 @@ jobs:
12598
- name: Install composer dependencies
12699
run: |
127100
composer update --prefer-dist --prefer-stable --prefer-lowest --no-interaction --no-progress
128-
vendor/bin/simple-phpunit install
129101
130102
- name: Execute tests
131-
run: vendor/bin/simple-phpunit -v
103+
run: vendor/bin/phpunit
132104

133105
varnish4:
134106
name: PHP ${{ matrix.php }} Legacy Varnish 4
@@ -141,7 +113,7 @@ jobs:
141113
fail-fast: false
142114
matrix:
143115
include:
144-
- php: '7.4'
116+
- php: '8.1'
145117

146118
steps:
147119
- name: Setup PHP
@@ -162,10 +134,9 @@ jobs:
162134
- name: Install composer dependencies
163135
run: |
164136
composer update --prefer-dist --prefer-stable --prefer-lowest --no-interaction --no-progress
165-
vendor/bin/simple-phpunit install
166137
167138
- name: Execute tests
168-
run: vendor/bin/simple-phpunit -v
139+
run: vendor/bin/phpunit
169140

170141
lowest:
171142
name: PHP ${{ matrix.php }} Lowest, Varnish 3
@@ -178,7 +149,7 @@ jobs:
178149
strategy:
179150
fail-fast: false
180151
matrix:
181-
php: ['7.2']
152+
php: ['8.1']
182153

183154
steps:
184155
- name: Setup PHP
@@ -199,10 +170,9 @@ jobs:
199170
- name: Install composer dependencies
200171
run: |
201172
composer update --prefer-dist --prefer-stable --prefer-lowest --no-interaction --no-progress
202-
vendor/bin/simple-phpunit install
203173
204174
- name: Execute tests
205-
run: vendor/bin/simple-phpunit -v
175+
run: vendor/bin/phpunit
206176

207177
coverage:
208178
name: Code Coverage
@@ -215,7 +185,7 @@ jobs:
215185
- name: Setup PHP
216186
uses: shivammathur/setup-php@v2
217187
with:
218-
php-version: 7.4
188+
php-version: 8.2
219189
tools: composer:v2
220190
coverage: xdebug
221191

@@ -229,14 +199,8 @@ jobs:
229199
230200
- name: Install dependencies
231201
run: |
232-
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
233203
composer update --prefer-dist --no-interaction --no-progress
234-
vendor/bin/simple-phpunit install
235204
236205
- name: Execute tests
237-
run: vendor/bin/simple-phpunit -v --coverage-text --coverage-clover build/coverage.xml
238-
239-
- name: Upload coverage
240-
run: |
241-
wget https://scrutinizer-ci.com/ocular.phar
242-
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",
26-
"symfony/options-resolver": "^4.3 || ^5.0 || ^6.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",
39-
"symfony/http-kernel": "^4.3 || ^5.0 || ^6.0",
40-
"symfony/phpunit-bridge": "^5.0 || ^6.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)