From ce759bb402809d182dde1e819effedfa85f9006c Mon Sep 17 00:00:00 2001 From: Rindert Vonk Date: Sun, 12 Dec 2021 16:28:17 +0100 Subject: [PATCH] Update for symfony 5 (#20) --- composer.json | 4 ++-- src/DependencyInjection/Configuration.php | 12 ++++++------ src/Twig/HtmlDiffExtension.php | 10 +++++----- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/composer.json b/composer.json index b92dde9..7e540eb 100644 --- a/composer.json +++ b/composer.json @@ -13,8 +13,8 @@ } ], "require": { - "php": ">=5.3.9", - "symfony/framework-bundle": "~2.3||3.*||4.*", + "php": ">=7.0", + "symfony/framework-bundle": "~2.3||3.*||4.*||5.*||6.*", "caxy/php-htmldiff": "~0.1" }, "require-dev": { diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 17ea23e..4da28d6 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -16,10 +16,10 @@ class Configuration implements ConfigurationInterface /** * {@inheritDoc} */ - public function getConfigTreeBuilder() + public function getConfigTreeBuilder(): TreeBuilder { - $treeBuilder = new TreeBuilder(); - $rootNode = $treeBuilder->root('caxy_html_diff'); + $treeBuilder = new TreeBuilder('caxy_html_diff'); + $rootNode = $treeBuilder->getRootNode(); $rootNode ->children() @@ -52,10 +52,10 @@ public function getConfigTreeBuilder() * * @return ArrayNodeDefinition */ - private function getDoctrineCacheDriverNode($name) + private function getDoctrineCacheDriverNode($name): ArrayNodeDefinition { - $treeBuilder = new TreeBuilder(); - $node = $treeBuilder->root($name); + $treeBuilder = new TreeBuilder($name); + $node = $treeBuilder->getRootNode(); $node ->canBeEnabled() ->beforeNormalization() diff --git a/src/Twig/HtmlDiffExtension.php b/src/Twig/HtmlDiffExtension.php index 12fb198..20b679a 100644 --- a/src/Twig/HtmlDiffExtension.php +++ b/src/Twig/HtmlDiffExtension.php @@ -4,7 +4,7 @@ use Caxy\HtmlDiffBundle\Service\HtmlDiffService; -class HtmlDiffExtension extends \Twig_Extension +class HtmlDiffExtension extends \Twig\Extension\AbstractExtension { protected $container; @@ -15,10 +15,10 @@ public function __construct(HtmlDiffService $htmlDiff) $this->htmlDiff = $htmlDiff; } - public function getFunctions() + public function getFunctions(): array { return array( - new \Twig_SimpleFunction('htmldiff', array($this, 'htmlDiff'), array('is_safe' => array('html'))), + new \Twig\TwigFunction('htmldiff', array($this, 'htmlDiff'), array('is_safe' => array('html'))), ); } @@ -27,8 +27,8 @@ public function htmlDiff($a, $b) return $this->htmlDiff->diff((string) $a, (string) $b); } - public function getName() + public function getName(): string { return 'caxy_htmldiff_extension'; } -} \ No newline at end of file +}