Skip to content

Commit d646991

Browse files
authored
Merge pull request #533 from FriendsOfSymfony/symfony-5
symfony 5 compatibility
2 parents cb8b530 + f8a1f72 commit d646991

32 files changed

+237
-98
lines changed

.styleci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@ preset: symfony
33
enabled:
44
- alpha_ordered_imports
55
- short_array_syntax
6+
7+
disabled:
8+
- single_line_throw

.travis.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,15 @@ matrix:
2828
include:
2929
# Minimum supported dependencies with the latest and oldest PHP version
3030

31-
- php: 7.1
32-
env:
33-
- COMPOSER_FLAGS="--prefer-stable --prefer-lowest"
3431
- php: 7.2
3532
env:
36-
- COMPOSER_FLAGS="--prefer-stable --prefer-lowest"
33+
- COMPOSER_FLAGS="--prefer-stable --prefer-lowest" DEPENDENCIES="symfony/validator:^3.4.4 symfony/templating:^3.4.4"
34+
- php: 7.3
35+
env:
36+
- COMPOSER_FLAGS="--prefer-stable --prefer-lowest" DEPENDENCIES="symfony/validator:^3.4.4 symfony/templating:^3.4.4"
3737

3838
# Test the latest stable release
3939

40-
- php: 7.1
4140
- php: 7.2
4241
- php: 7.3
4342
env:
@@ -49,6 +48,9 @@ matrix:
4948
- php: 7.3
5049
env: DEPENDENCIES="symfony/lts:^3"
5150

51+
- php: 7.3
52+
env: DEPENDENCIES="symfony/flex" SYMFONY_VERSION="^4"
53+
5254
# Latest commit to master
5355
- php: 7.3
5456
env: STABILITY="dev"
@@ -60,7 +62,8 @@ matrix:
6062
before_install:
6163
- if [[ $COVERAGE != true ]]; then phpenv config-rm xdebug.ini || true; fi
6264
- if ! [ -z "$STABILITY" ]; then composer config minimum-stability ${STABILITY}; fi;
63-
- if ! [ -v "$DEPENDENCIES" ]; then composer require --no-update ${DEPENDENCIES}; fi;
65+
- if ! [ -z "$DEPENDENCIES" ]; then composer require --no-update ${DEPENDENCIES}; fi;
66+
- if ! [ -z "$SYMFONY_VERSION" ]; then composer config extra.symfony.require ${SYMFONY_VERSION}; fi;
6467

6568
install:
6669
# To be removed when this issue will be resolved: https://github.com/composer/composer/issues/5355

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
Changelog
22
=========
33

4+
2.8.0
5+
-----
6+
7+
### Fixed
8+
9+
* Adjusted to work with Twig 3
10+
* Adjusted to work with Symfony 5
11+
412
2.7.2
513
-----
614

composer.json

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,30 +21,30 @@
2121
}
2222
],
2323
"require": {
24-
"php": "^7.1",
24+
"php": "^7.2",
2525
"friendsofsymfony/http-cache": "^2.5.2",
26-
"symfony/framework-bundle": "^3.4.4 || ^4.0",
27-
"symfony/http-foundation": "^3.4.4 || ^4.0",
28-
"symfony/http-kernel": "^3.4.4 || ^4.0"
26+
"symfony/framework-bundle": "^3.4.4 || ^4.1.12 || ^5.0",
27+
"symfony/http-foundation": "^3.4.4 || ^4.1.12 || ^5.0",
28+
"symfony/http-kernel": "^3.4.4 || ^4.1.12 || ^5.0"
2929
},
3030
"require-dev": {
3131
"php-http/guzzle6-adapter": "^1.0 || ^2.0",
3232
"php-http/message": "^1.0",
3333
"mockery/mockery": "^1.0",
3434
"monolog/monolog": "*",
35-
"sensio/framework-extra-bundle": "^3.0",
36-
"symfony/browser-kit": "^3.4.4 || ^4.0",
37-
"symfony/console": "^3.4.4 || ^4.0",
38-
"symfony/finder": "^3.4.4 || ^4.0",
39-
"symfony/phpunit-bridge": "^4.2.4",
40-
"symfony/security-bundle": "^3.4.4 || ^4.0",
41-
"symfony/twig-bundle": "^3.4.4 || ^4.0",
42-
"symfony/yaml": "^3.4.4 || ^4.0",
43-
"symfony/css-selector": "^3.4.4 || ^4.0",
44-
"symfony/expression-language": "^3.4.4 || ^4.0",
45-
"symfony/monolog-bundle": "^3.0",
46-
"symfony/routing": "^3.4.4 || ^4.0",
47-
"matthiasnoback/symfony-dependency-injection-test": "^2.3",
35+
"sensio/framework-extra-bundle": "^3.0 || ^4.0 || ^5.0",
36+
"symfony/browser-kit": "^3.4.4 || ^4.1.12 || ^5.0",
37+
"symfony/console": "^3.4.4 || ^4.1.12 || ^5.0",
38+
"symfony/finder": "^3.4.4 || ^4.1.12 || ^5.0",
39+
"symfony/phpunit-bridge": "^4.2.4 || ^5.0",
40+
"symfony/security-bundle": "^3.4.4 || ^4.1.12 || ^5.0",
41+
"symfony/twig-bundle": "^3.4.4 || ^4.1.12 || ^5.0",
42+
"symfony/yaml": "^3.4.4 || ^4.1.12 || ^5.0",
43+
"symfony/css-selector": "^3.4.4 || ^4.1.12 || ^5.0",
44+
"symfony/expression-language": "^3.4.4 || ^4.1.12 || ^5.0",
45+
"symfony/monolog-bundle": "^3.0 || ^4.1.12 || ^5.0",
46+
"symfony/routing": "^3.4.4 || ^4.1.12 || ^5.0",
47+
"matthiasnoback/symfony-dependency-injection-test": "^4.0",
4848
"sebastian/exporter": "^2.0"
4949
},
5050
"suggest": {
@@ -71,7 +71,7 @@
7171
},
7272
"extra": {
7373
"branch-alias": {
74-
"dev-master": "2.5.x-dev"
74+
"dev-master": "2.x-dev"
7575
}
7676
}
7777
}

src/Command/InvalidatePathCommand.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,5 +80,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
8080

8181
$this->getCacheManager()->invalidatePath($path);
8282
}
83+
84+
return 0;
8385
}
8486
}

src/Command/InvalidateRegexCommand.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
7777
$regex = $input->getArgument('regex');
7878

7979
$this->getCacheManager()->invalidateRegex($regex);
80+
81+
return 0;
8082
}
8183
}

src/Command/InvalidateTagCommand.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
7272
$tags = $input->getArgument('tags');
7373

7474
$this->getCacheManager()->invalidateTags($tags);
75+
76+
return 0;
7577
}
7678
}

src/Command/RefreshPathCommand.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,5 +80,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
8080

8181
$this->getCacheManager()->refreshPath($path);
8282
}
83+
84+
return 0;
8385
}
8486
}

src/EventListener/CacheControlListener.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,16 @@
1616
use Symfony\Component\HttpFoundation\Request;
1717
use Symfony\Component\HttpFoundation\Response;
1818
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
19+
use Symfony\Component\HttpKernel\Event\ResponseEvent;
20+
use Symfony\Component\HttpKernel\Kernel;
1921
use Symfony\Component\HttpKernel\KernelEvents;
2022

23+
if (Kernel::MAJOR_VERSION >= 5) {
24+
class_alias(ResponseEvent::class, 'FOS\HttpCacheBundle\EventListener\CacheControlResponseEvent');
25+
} else {
26+
class_alias(FilterResponseEvent::class, 'FOS\HttpCacheBundle\EventListener\CacheControlResponseEvent');
27+
}
28+
2129
/**
2230
* Set caching settings on matching response according to the configurations.
2331
*
@@ -95,10 +103,8 @@ public function setSkip($skip = true)
95103

96104
/**
97105
* Apply the header rules if the request matches.
98-
*
99-
* @param FilterResponseEvent $event
100106
*/
101-
public function onKernelResponse(FilterResponseEvent $event)
107+
public function onKernelResponse(CacheControlResponseEvent $event)
102108
{
103109
$request = $event->getRequest();
104110
$response = $event->getResponse();

src/EventListener/FlashMessageListener.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,18 @@
1616
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
1717
use Symfony\Component\HttpFoundation\Session\Session;
1818
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
19+
use Symfony\Component\HttpKernel\Event\ResponseEvent;
1920
use Symfony\Component\HttpKernel\HttpKernel;
21+
use Symfony\Component\HttpKernel\Kernel;
2022
use Symfony\Component\HttpKernel\KernelEvents;
2123
use Symfony\Component\OptionsResolver\OptionsResolver;
2224

25+
if (Kernel::MAJOR_VERSION >= 5) {
26+
class_alias(ResponseEvent::class, 'FOS\HttpCacheBundle\EventListener\FlashMessageResponseEvent');
27+
} else {
28+
class_alias(FilterResponseEvent::class, 'FOS\HttpCacheBundle\EventListener\FlashMessageResponseEvent');
29+
}
30+
2331
/**
2432
* This event handler reads all flash messages and moves them into a cookie.
2533
*
@@ -66,10 +74,8 @@ public static function getSubscribedEvents()
6674

6775
/**
6876
* Moves flash messages from the session to a cookie inside a Response Kernel listener.
69-
*
70-
* @param FilterResponseEvent $event
7177
*/
72-
public function onKernelResponse(FilterResponseEvent $event)
78+
public function onKernelResponse(FlashMessageResponseEvent $event)
7379
{
7480
if (HttpKernel::MASTER_REQUEST !== $event->getRequestType()) {
7581
return;

0 commit comments

Comments
 (0)