Skip to content

Commit

Permalink
Fix code-level breaking changes for Symfony 5 (#35)
Browse files Browse the repository at this point in the history
* fix Symfony 5 breaking change (removal of FilterResponseEvent class)

* set explicit dependency on twig (excluding Twig 3+ because of BC)

* set php requirement to >=5.4 because of php traits usage

* remove unused imports

* disable \Twig_Environment constructor invocation in a test case

* configure Travis CI to check all php versions between 5.4 and 7.4

* remove php7.4 from Travis CI configuration because it is not available

Co-authored-by: Valentin Sviridov <fogeiner@gmail.com>
  • Loading branch information
2 people authored and xyNNN committed Jan 21, 2020
1 parent e4a63b0 commit e293357
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
language: php

php:
- 5.3
- 5.4
- 5.5
- 5.6
- 7.0
- 7.1
- 7.2
- 7.3
- nightly

sudo: false
Expand Down
10 changes: 4 additions & 6 deletions EventListener/GoogleTagManagerListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace Xynnn\GoogleTagManagerBundle\EventListener;

use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Xynnn\GoogleTagManagerBundle\Twig\GoogleTagManagerExtension;

/**
Expand Down Expand Up @@ -41,11 +39,11 @@ public function __construct(\Twig_Environment $environment, GoogleTagManagerExte
}

/**
* @param FilterResponseEvent $event
* @param mixed $event FilterResponseEvent before Symfony 5 and ResponseEvent afterwards
*
* @return bool
*/
public function onKernelResponse(FilterResponseEvent $event)
public function onKernelResponse($event)
{
if (!$this->allowRender($event)) {
return false;
Expand Down Expand Up @@ -80,11 +78,11 @@ public function onKernelResponse(FilterResponseEvent $event)
}

/**
* @param FilterResponseEvent $event
* @param mixed $event FilterResponseEvent before Symfony 5 and ResponseEvent afterwards
*
* @return bool
*/
private function allowRender(FilterResponseEvent $event)
private function allowRender($event)
{
// not configured to append automatically
if (!$this->autoAppend) {
Expand Down
2 changes: 0 additions & 2 deletions Helper/GoogleTagManagerHelperInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@

namespace Xynnn\GoogleTagManagerBundle\Helper;

use Symfony\Component\Templating\Helper\Helper;
use Symfony\Component\Templating\Helper\HelperInterface;
use Xynnn\GoogleTagManagerBundle\Service\GoogleTagManagerInterface;

/**
* Interface GoogleTagManagerHelperInterface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ protected function setUp()
$this->extension = new GoogleTagManagerExtension();

$this->container = new ContainerBuilder();
$this->container->register('twig', $this->getMockBuilder('\Twig_Environment')->getMock());
$this->container->register('twig', $this->getMockBuilder('\Twig_Environment')->disableOriginalConstructor()->getMock());
$this->container->registerExtension($this->extension);
}

Expand Down
2 changes: 0 additions & 2 deletions Twig/GoogleTagManagerExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@

namespace Xynnn\GoogleTagManagerBundle\Twig;

use Symfony\Component\Templating\Helper\HelperInterface;
use Twig_Extension;
use Xynnn\GoogleTagManagerBundle\Helper\GoogleTagManagerHelper;
use Xynnn\GoogleTagManagerBundle\Helper\GoogleTagManagerHelperInterface;

/**
Expand Down
8 changes: 6 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@
],
"minimum-stability": "dev",
"require": {
"php": ">=5.3.2",
"php": ">=5.4",
"symfony/dependency-injection": "~2.8|~3.0|~4.0|~5.0",
"symfony/http-kernel": "~2.8|~3.0|~4.0|~5.0",
"symfony/config": "~2.8|~3.0|~4.0|~5.0",
"symfony/templating": "~2.8|~3.0|~4.0|~5.0"
"symfony/templating": "~2.8|~3.0|~4.0|~5.0",
"twig/twig": "~1.23|~2.0"
},
"conflict": {
"twig/twig": ">=3.0"
},
"require-dev": {
"phpunit/phpunit": "~4.3"
Expand Down

0 comments on commit e293357

Please sign in to comment.