Skip to content

Commit

Permalink
adjust for symfony 7
Browse files Browse the repository at this point in the history
  • Loading branch information
dbu committed Dec 11, 2023
1 parent 0761a0b commit 98737de
Show file tree
Hide file tree
Showing 15 changed files with 122 additions and 210 deletions.
68 changes: 11 additions & 57 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,8 @@ jobs:
matrix:
varnish-version: ['6.6']
varnish-modules-version: ['0.18.0']
php: ['7.3', '7.4', '8.0', '8.1']
php: ['8.1', '8.2', '8.3']
include:
- php: '7.4'
symfony-version: '4.3.*'
- php: '7.4'
symfony-version: '5.0.*'
- php: '8.1'
symfony-version: '6.*'
- php: '8.1'
Expand Down Expand Up @@ -66,42 +62,9 @@ jobs:
run: |
composer require --no-update ${DEPENDENCIES}
composer update --prefer-dist --no-interaction --no-progress
vendor/bin/simple-phpunit install
- name: Execute tests
run: vendor/bin/simple-phpunit -v

legacyPHP:
name: PHP 7.2 Varnish 6
runs-on: ubuntu-20.04
env:
VARNISH_VERSION: '6.6'
VARNISH_MODULES_VERSION: '0.18.0'

steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.2
tools: composer:v2
coverage: none

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

- name: Setup Varnish and Nginx
run: |
sh ${GITHUB_WORKSPACE}/.github/workflows/setup-varnish.sh
sh ${GITHUB_WORKSPACE}/.github/workflows/setup-nginx.sh
- name: Install composer dependencies
run: |
composer require --no-update ${DEPENDENCIES}
composer update --prefer-dist --no-interaction --no-progress
vendor/bin/simple-phpunit install
- name: Execute tests
run: vendor/bin/simple-phpunit -v
run: vendor/bin/phpunit

varnish5:
name: PHP ${{ matrix.php }} Legacy Varnish 5
Expand All @@ -114,7 +77,7 @@ jobs:
fail-fast: false
matrix:
include:
- php: '7.4'
- php: '8.1'

steps:
- name: Setup PHP
Expand All @@ -135,10 +98,9 @@ jobs:
- name: Install composer dependencies
run: |
composer update --prefer-dist --prefer-stable --prefer-lowest --no-interaction --no-progress
vendor/bin/simple-phpunit install
- name: Execute tests
run: vendor/bin/simple-phpunit -v
run: vendor/bin/phpunit

varnish4:
name: PHP ${{ matrix.php }} Legacy Varnish 4
Expand All @@ -151,7 +113,7 @@ jobs:
fail-fast: false
matrix:
include:
- php: '7.4'
- php: '8.1'

steps:
- name: Setup PHP
Expand All @@ -172,10 +134,9 @@ jobs:
- name: Install composer dependencies
run: |
composer update --prefer-dist --prefer-stable --prefer-lowest --no-interaction --no-progress
vendor/bin/simple-phpunit install
- name: Execute tests
run: vendor/bin/simple-phpunit -v
run: vendor/bin/phpunit

lowest:
name: PHP ${{ matrix.php }} Lowest, Varnish 3
Expand All @@ -188,7 +149,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ['7.2']
php: ['8.1']

steps:
- name: Setup PHP
Expand All @@ -209,10 +170,9 @@ jobs:
- name: Install composer dependencies
run: |
composer update --prefer-dist --prefer-stable --prefer-lowest --no-interaction --no-progress
vendor/bin/simple-phpunit install
- name: Execute tests
run: vendor/bin/simple-phpunit -v
run: vendor/bin/phpunit

coverage:
name: Code Coverage
Expand All @@ -225,7 +185,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
php-version: 8.2
tools: composer:v2
coverage: xdebug

Expand All @@ -239,14 +199,8 @@ jobs:
- name: Install dependencies
run: |
composer require "friends-of-phpspec/phpspec-code-coverage:^4.3.2" --no-interaction --no-update
composer require "friends-of-phpspec/phpspec-code-coverage:^6.3.0" --no-interaction --no-update
composer update --prefer-dist --no-interaction --no-progress
vendor/bin/simple-phpunit install
- name: Execute tests
run: vendor/bin/simple-phpunit -v --coverage-text --coverage-clover build/coverage.xml

- name: Upload coverage
run: |
wget https://scrutinizer-ci.com/ocular.phar
php ocular.phar code-coverage:upload --format=php-clover build/coverage.xml --revision=${{ github.event.pull_request.head.sha || github.sha }}
run: vendor/bin/phpunit --coverage-text --coverage-clover build/coverage.xml
6 changes: 2 additions & 4 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@ jobs:
phpstan-src:
name: PHPStan src
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:^3.0
run: composer require --no-update phpunit/phpunit toflar/psr6-symfony-http-cache-store:^4.2

- name: PHPStan
uses: docker://oskarstark/phpstan-ga
Expand All @@ -36,7 +34,7 @@ jobs:
uses: actions/checkout@v2

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

- name: PHPStan
uses: docker://oskarstark/phpstan-ga
Expand Down
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@ Changelog

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

3.x
===

3.0.0 (unreleased)
-----

* Support Symfony 7
* Drop support for Symfony < 6.4
* Test with PHP 8.2 and 8.3
* Drop support for PHP < 8.1
* Parameter and return type declarations where possible.

2.x
===

2.15.3
------

Expand Down
16 changes: 8 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,23 @@
}
],
"require": {
"php": "^7.2 || ^8.0",
"symfony/event-dispatcher": "^4.3 || ^5.0 || ^6.0 || ^7.0",
"symfony/options-resolver": "^4.3 || ^5.0 || ^6.0 || ^7.0",
"php": "^8.1",
"symfony/event-dispatcher": "^6.4 || ^7.0",
"symfony/options-resolver": "^6.4 || ^7.0",
"php-http/client-implementation": "^1.0 || ^2.0",
"php-http/client-common": "^1.1.0 || ^2.0",
"php-http/message": "^1.0 || ^2.0",
"php-http/message-factory": "^1.0",
"php-http/discovery": "^1.12"
},
"require-dev": {
"mockery/mockery": "^1.3.1",
"mockery/mockery": "^1.6.0",
"monolog/monolog": "^1.0",
"php-http/guzzle7-adapter": "^0.1.1",
"php-http/mock-client": "^1.2",
"symfony/process": "^4.3 || ^5.0 || ^6.0|| ^7.0",
"symfony/http-kernel": "^4.3 || ^5.0 || ^6.0|| ^7.0",
"symfony/phpunit-bridge": "^5.0 || ^6.0|| ^7.0"
"php-http/mock-client": "^1.6.0",
"symfony/process": "^6.4|| ^7.0",
"symfony/http-kernel": "^6.4|| ^7.0",
"phpunit/phpunit": "^9"
},
"conflict": {
"toflar/psr6-symfony-http-cache-store": "<2.2.1"
Expand Down
13 changes: 3 additions & 10 deletions src/SymfonyCache/AccessControlledListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestMatcher;
use Symfony\Component\HttpFoundation\RequestMatcher\IpsRequestMatcher;
use Symfony\Component\HttpFoundation\RequestMatcherInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
Expand All @@ -26,10 +25,7 @@
*/
abstract class AccessControlledListener implements EventSubscriberInterface
{
/**
* @var RequestMatcherInterface
*/
private $clientMatcher;
private RequestMatcherInterface $clientMatcher;

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

$this->clientMatcher = $clientMatcher;
Expand Down
40 changes: 11 additions & 29 deletions src/SymfonyCache/CacheEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,35 +23,23 @@
*/
class CacheEvent extends BaseEvent
{
/**
* @var CacheInvalidation
*/
private $kernel;
private CacheInvalidation $kernel;

/**
* @var Request
*/
private $request;
private Request $request;

/**
* @var Response
*/
private $response;
private ?Response $response;

/**
* @var int
*/
private $requestType;
private int $requestType;

/**
* Make sure your $kernel implements CacheInvalidationInterface.
*
* @param CacheInvalidation $kernel the kernel raising with this event
* @param Request $request the request being processed
* @param Response|null $response the response, if available
* @param int $requestType the request type (default HttpKernelInterface::MASTER_REQUEST)
* @param int $requestType the request type (default HttpKernelInterface::MAIN_REQUEST)
*/
public function __construct(CacheInvalidation $kernel, Request $request, Response $response = null, $requestType = HttpKernelInterface::MASTER_REQUEST)
public function __construct(CacheInvalidation $kernel, Request $request, Response $response = null, int $requestType = HttpKernelInterface::MAIN_REQUEST)
{
$this->kernel = $kernel;
$this->request = $request;
Expand All @@ -71,31 +59,25 @@ public function getKernel()

/**
* Get the request that is being processed.
*
* @return Request
*/
public function getRequest()
public function getRequest(): Request
{
return $this->request;
}

/**
* One of the constants HttpKernelInterface::MASTER_REQUEST or SUB_REQUEST.
*
* @return int
* One of the constants HttpKernelInterface::MAIN_REQUEST or SUB_REQUEST.
*/
public function getRequestType()
public function getRequestType(): int
{
return $this->requestType;
}

/**
* Events that occur after the response is created provide the default response.
* Event listeners can also set the response to make it available here.
*
* @return Response|null the response if one was set
*/
public function getResponse()
public function getResponse(): ?Response
{
return $this->response;
}
Expand All @@ -105,7 +87,7 @@ public function getResponse()
*
* Setting a response stops propagation of the event to further event handlers.
*/
public function setResponse(Response $response)
public function setResponse(Response $response): void
{
$this->response = $response;

Expand Down
Loading

0 comments on commit 98737de

Please sign in to comment.