Skip to content

Commit

Permalink
Merge pull request #929 from rosier/twig-deprecations
Browse files Browse the repository at this point in the history
Fix deprecations from newer twig versions
  • Loading branch information
alcaeus committed Apr 1, 2019
2 parents db0f5bb + 8bb4e4d commit 3597c27
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
14 changes: 7 additions & 7 deletions Tests/ProfilerTest.php
Expand Up @@ -17,16 +17,16 @@
use Symfony\Component\HttpKernel\Fragment\FragmentHandler;
use Symfony\Component\HttpKernel\Profiler\Profile;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Twig_Environment;
use Twig_Loader_Filesystem;
use Twig_RuntimeLoaderInterface;
use Twig\Environment;
use Twig\Loader\FilesystemLoader;
use Twig\RuntimeLoader\RuntimeLoaderInterface;

class ProfilerTest extends BaseTestCase
{
/** @var DebugStack */
private $logger;

/** @var Twig_Environment */
/** @var Environment */
private $twig;

/** @var DoctrineDataCollector */
Expand All @@ -40,17 +40,17 @@ public function setUp()
$this->collector = new DoctrineDataCollector($registry);
$this->collector->addLogger('foo', $this->logger);

$twigLoaderFilesystem = new Twig_Loader_Filesystem(__DIR__ . '/../Resources/views/Collector');
$twigLoaderFilesystem = new FilesystemLoader(__DIR__ . '/../Resources/views/Collector');
$twigLoaderFilesystem->addPath(__DIR__ . '/../vendor/symfony/web-profiler-bundle/Resources/views', 'WebProfiler');
$this->twig = new Twig_Environment($twigLoaderFilesystem, ['debug' => true, 'strict_variables' => true]);
$this->twig = new Environment($twigLoaderFilesystem, ['debug' => true, 'strict_variables' => true]);

$this->twig->addExtension(new CodeExtension('', '', ''));
$this->twig->addExtension(new RoutingExtension($this->getMockBuilder(UrlGeneratorInterface::class)->getMock()));
$this->twig->addExtension(new HttpKernelExtension($this->getMockBuilder(FragmentHandler::class)->disableOriginalConstructor()->getMock()));
$this->twig->addExtension(new WebProfilerExtension());
$this->twig->addExtension(new DoctrineExtension());

$loader = $this->getMockBuilder(Twig_RuntimeLoaderInterface::class)->getMock();
$loader = $this->getMockBuilder(RuntimeLoaderInterface::class)->getMock();
$loader->method('load')->willReturn($this->getMockBuilder(HttpKernelRuntime::class)->disableOriginalConstructor()->getMock());
$this->twig->addRuntimeLoader($loader);
}
Expand Down
14 changes: 7 additions & 7 deletions Twig/DoctrineExtension.php
Expand Up @@ -4,13 +4,13 @@

use SqlFormatter;
use Symfony\Component\VarDumper\Cloner\Data;
use Twig_Extension;
use Twig_SimpleFilter;
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;

/**
* This class contains the needed functions in order to do the query highlighting
*/
class DoctrineExtension extends Twig_Extension
class DoctrineExtension extends AbstractExtension
{
/**
* Number of maximum characters that one single line can hold in the interface
Expand All @@ -22,14 +22,14 @@ class DoctrineExtension extends Twig_Extension
/**
* Define our functions
*
* @return Twig_SimpleFilter[]
* @return TwigFilter[]
*/
public function getFilters()
{
return [
new Twig_SimpleFilter('doctrine_minify_query', [$this, 'minifyQuery'], ['deprecated' => true]),
new Twig_SimpleFilter('doctrine_pretty_query', [$this, 'formatQuery'], ['is_safe' => ['html']]),
new Twig_SimpleFilter('doctrine_replace_query_parameters', [$this, 'replaceQueryParameters']),
new TwigFilter('doctrine_minify_query', [$this, 'minifyQuery'], ['deprecated' => true]),
new TwigFilter('doctrine_pretty_query', [$this, 'formatQuery'], ['is_safe' => ['html']]),
new TwigFilter('doctrine_replace_query_parameters', [$this, 'replaceQueryParameters']),
];
}

Expand Down
5 changes: 3 additions & 2 deletions composer.json
Expand Up @@ -40,14 +40,15 @@
"symfony/validator": "^3.4|^4.1",
"symfony/property-info": "^3.4|^4.1",
"symfony/phpunit-bridge": "^4.2",
"twig/twig": "^1.26|^2.0",
"twig/twig": "^1.34|^2.4",
"php-coveralls/php-coveralls": "^2.1",
"phpunit/phpunit": "7.0",
"symfony/web-profiler-bundle": "^3.4|^4.1",
"doctrine/coding-standard": "^5.0"
},
"conflict": {
"doctrine/orm": "<2.6"
"doctrine/orm": "<2.6",
"twig/twig": "<1.34|>=2.0,<2.4"
},
"suggest": {
"symfony/web-profiler-bundle": "To use the data collector.",
Expand Down

0 comments on commit 3597c27

Please sign in to comment.