Skip to content

Commit 44cf127

Browse files
authored
Merge pull request #136 from amacrobert-meq/symfony-7-support
Symfony 7 support
2 parents 07bdfaa + 5e8f9f7 commit 44cf127

File tree

5 files changed

+39
-17
lines changed

5 files changed

+39
-17
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,17 @@ jobs:
1212
matrix:
1313
php: [ "8.0", "8.1", "8.2", "8.3", "8.4" ]
1414
composer_flags: [ "", "--prefer-lowest" ]
15-
symfony_version: [ "^5.4", "^6.4" ]
15+
symfony_version: [ "^5.4", "^6.4", "^7.3" ]
1616
exclude:
17+
# Symfony 6 requires PHP 8.1+
1718
- php: "8.0"
1819
symfony_version: "^6.4"
20+
# Symfony 7 requires PHP 8.2+
21+
- php: "8.0"
22+
symfony_version: "^7.3"
23+
- php: "8.1"
24+
symfony_version: "^7.3"
25+
1926
name: PHP ${{ matrix.php }} SF ${{ matrix.symfony_version }} ${{ matrix.composer_flags}}
2027
env:
2128
PHP: ${{ matrix.os }}
@@ -38,7 +45,7 @@ jobs:
3845
run: |
3946
composer self-update
4047
if [ "$SYMFONY_VERSION" != "" ]; then composer require "symfony/symfony:${SYMFONY_VERSION}" --no-update; fi;
41-
if [ "$SYMFONY_VERSION" = "^6.4" ]; then composer remove --dev "friendsofsymfony/oauth-server-bundle" --no-update; fi;
48+
if [ "$SYMFONY_VERSION" != "^5.4" ]; then composer remove --dev "friendsofsymfony/oauth-server-bundle" --no-update; fi;
4249
COMPOSER_MEMORY_LIMIT=-1 composer update --prefer-dist --no-interaction $COMPOSER_FLAGS
4350
- name: Static analysis
4451
run: |

EventListener/RateLimitAnnotationListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function onKernelController(ControllerEvent $event): void
4141
}
4242

4343
// Skip if we aren't the main request
44-
if ($event->getRequestType() !== HttpKernelInterface::MASTER_REQUEST) {
44+
if ($event->getRequestType() !== HttpKernelInterface::MAIN_REQUEST) {
4545
return;
4646
}
4747

Tests/EventListener/RateLimitAnnotationListenerTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function testReturnedWhenNoControllerFound(): void
6464
$kernel = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\HttpKernelInterface')->getMock();
6565
$request = new Request();
6666

67-
$event = new ControllerEvent($kernel, static function() {}, $request, HttpKernelInterface::MASTER_REQUEST);
67+
$event = new ControllerEvent($kernel, static function() {}, $request, HttpKernelInterface::MAIN_REQUEST);
6868

6969
$listener->onKernelController($event);
7070
}
@@ -81,7 +81,7 @@ public function testReturnedWhenNoAttributesFound(): void
8181
public function testDelegatesToPathLimitProcessorWhenNoAttributesFound(): void
8282
{
8383
$request = new Request();
84-
$event = $this->createEvent(HttpKernelInterface::MASTER_REQUEST, $request);
84+
$event = $this->createEvent(HttpKernelInterface::MAIN_REQUEST, $request);
8585

8686
$listener = $this->createListener($this->once());
8787

@@ -109,7 +109,7 @@ public function testDispatchIsCalledWithAttributes(): void
109109
$listener = $this->createListener($this->exactly(2));
110110

111111
$event = $this->createEvent(
112-
HttpKernelInterface::MASTER_REQUEST,
112+
HttpKernelInterface::MAIN_REQUEST,
113113
null,
114114
new MockControllerWithAttributes()
115115
);
@@ -119,7 +119,7 @@ public function testDispatchIsCalledWithAttributes(): void
119119

120120
public function testDispatchIsCalledIfThePathLimitProcessorReturnsARateLimit(): void
121121
{
122-
$event = $this->createEvent(HttpKernelInterface::MASTER_REQUEST);
122+
$event = $this->createEvent(HttpKernelInterface::MAIN_REQUEST);
123123

124124
$listener = $this->createListener($this->exactly(2));
125125
$rateLimit = new RateLimit(
@@ -315,7 +315,7 @@ public function testFindBestMethodMatchMatchingMultipleAnnotations(): void
315315
}
316316

317317
protected function createEvent(
318-
int $requestType = HttpKernelInterface::MASTER_REQUEST,
318+
int $requestType = HttpKernelInterface::MAIN_REQUEST,
319319
?Request $request = null,
320320
?MockController $controller = null,
321321
): ControllerEvent

Tests/Service/Storage/PsrCacheTest.php

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,27 @@ public function testCreateRate()
3737
{
3838
$item = $this->getMockBuilder('Psr\\Cache\\CacheItemInterface')
3939
->getMock();
40-
$item->expects($this->once())
41-
->method('set')
42-
->willReturn(true);
43-
$item->expects($this->once())
44-
->method('expiresAfter')
45-
->willReturn(true);
40+
41+
/**
42+
* psr/cache 3.0 changed the return type of set() and expiresAfter() to return self.
43+
* @TODO NEXT_MAJOR: Remove this check and the first conditional block when psr/cache <3 support is dropped.
44+
*/
45+
$psrCacheVersion = \Composer\InstalledVersions::getVersion('psr/cache');
46+
if (version_compare($psrCacheVersion, '3.0', '<')) {
47+
$item->expects($this->once())
48+
->method('set')
49+
->willReturn(true);
50+
$item->expects($this->once())
51+
->method('expiresAfter')
52+
->willReturn(true);
53+
} else {
54+
$item->expects($this->once())
55+
->method('set')
56+
->willReturnSelf();
57+
$item->expects($this->once())
58+
->method('expiresAfter')
59+
->willReturnSelf();
60+
}
4661

4762
$client = $this->getMockBuilder('Psr\\Cache\\CacheItemPoolInterface')
4863
->getMock();
@@ -121,4 +136,4 @@ public function testResetRate()
121136
$storage = new PsrCache($client);
122137
$this->assertTrue($storage->resetRate('foo'));
123138
}
124-
}
139+
}

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
],
1313
"require": {
1414
"php": "^8.0",
15-
"symfony/framework-bundle": "^5.4.2|^6.4"
15+
"symfony/framework-bundle": "^5.4.2|^6.4|^7.3"
1616
},
1717
"require-dev": {
1818
"symfony/phpunit-bridge": ">=5.4",
1919
"psr/simple-cache": "^1.0|^2.0",
2020
"doctrine/cache": "^1.5",
21-
"psr/cache": "^1.0|^2.0",
21+
"psr/cache": "^1.0|^2.0|^3.0",
2222
"predis/predis": "^1.1|^2.0",
2323
"friendsofsymfony/oauth-server-bundle": "^1.5|^2.0@dev",
2424
"phpstan/phpstan": "^2.1"

0 commit comments

Comments
 (0)