From 1e9bcf67c29b2aba35ba9d8143bf5ad47d526805 Mon Sep 17 00:00:00 2001 From: Jean-Guilhem Rouel Date: Mon, 22 Aug 2016 08:22:55 +0100 Subject: [PATCH] Modernise constraints --- Tests/AbstractTestCase.php | 1 - Tests/Twig/Extension/LinkifyTwigExtensionTest.php | 8 ++++++-- Twig/Extension/LinkifyTwigExtension.php | 4 ++-- composer.json | 7 ++++--- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Tests/AbstractTestCase.php b/Tests/AbstractTestCase.php index 23a5efd..d9a7ff2 100644 --- a/Tests/AbstractTestCase.php +++ b/Tests/AbstractTestCase.php @@ -38,7 +38,6 @@ protected function getContainer(array $config = array(), KernelInterface $kernel $container->setParameter('kernel.cache_dir', sys_get_temp_dir() . '/linkify'); $container->setParameter('kernel.bundles', array()); $container->setParameter('kernel.root_dir', __DIR__ . '/Fixtures'); - $container->set('service_container', $container); $container->registerExtension($extension); $extension->load($config, $container); diff --git a/Tests/Twig/Extension/LinkifyTwigExtensionTest.php b/Tests/Twig/Extension/LinkifyTwigExtensionTest.php index 297b78a..d571b8a 100644 --- a/Tests/Twig/Extension/LinkifyTwigExtensionTest.php +++ b/Tests/Twig/Extension/LinkifyTwigExtensionTest.php @@ -13,6 +13,7 @@ use Misd\LinkifyBundle\Tests\AbstractTestCase; use Misd\LinkifyBundle\Twig\Extension\LinkifyTwigExtension; +use Twig_SimpleFilter; class LinkifyTwigExtensionTest extends AbstractTestCase { @@ -36,8 +37,11 @@ public function testFilters() $filters = $extension->getFilters(); - $this->assertArrayHasKey('linkify', $filters); - $this->assertInstanceOf('Twig_Filter_Method', $filters['linkify']); + $linkifyFilters = array_filter($filters, function (Twig_SimpleFilter $filter) { + return $filter->getName() === 'linkify'; + }); + + $this->assertCount(1, $linkifyFilters); } public function testLinkify() diff --git a/Twig/Extension/LinkifyTwigExtension.php b/Twig/Extension/LinkifyTwigExtension.php index 90dba82..aa07443 100644 --- a/Twig/Extension/LinkifyTwigExtension.php +++ b/Twig/Extension/LinkifyTwigExtension.php @@ -12,7 +12,7 @@ namespace Misd\LinkifyBundle\Twig\Extension; use Twig_Extension; -use Twig_Filter_Method; +use Twig_SimpleFilter; use Misd\LinkifyBundle\Helper\LinkifyHelper; /** @@ -41,7 +41,7 @@ public function __construct(LinkifyHelper $helper) public function getFilters() { return array( - 'linkify' => new Twig_Filter_Method($this, 'linkify', array( + new Twig_SimpleFilter('linkify', array($this, 'linkify'), array( 'pre_escape' => 'html', 'is_safe' => array('html') )), diff --git a/composer.json b/composer.json index a9a59d2..026be66 100644 --- a/composer.json +++ b/composer.json @@ -16,15 +16,16 @@ }, "require": { "php": "^5.3.3 || ^7.0", - "symfony/framework-bundle": "^2.1", + "symfony/framework-bundle": "^2.1 || ^3.0", "misd/linkify": "^1.0" }, "require-dev": { "phpunit/phpunit": "^4.0 || ^5.0", - "symfony/twig-bundle": "^2.1" + "symfony/twig-bundle": "^2.1 || ^3.0" }, "conflict": { - "phpunit/phpunit-mock-objects": "<2.2" + "phpunit/phpunit-mock-objects": "<2.2", + "twig/twig": "<1.23" }, "suggest": { "symfony/twig-bundle": "to use the Twig linkify filter"