From 6f05079d769b32a3f61629a0aa33f937a5374cec Mon Sep 17 00:00:00 2001 From: jmsche Date: Sat, 15 Dec 2018 16:15:21 +0100 Subject: [PATCH] Fixed deprecation with Symfony 4.2 (#164) * Fixed deprecation with Symfony 4.2 * Fixed deprecation with Symfony 4.2 - Try to fix CI (phpstan failing) * Fixed deprecation with Symfony 4.2 - Try to fix CI by increasing composer's memory limit * Fixed deprecation with Symfony 4.2 - Drop Distribution bundle dependency * Fixed deprecation with Symfony 4.2 - Removed composer custom memory limit * Fixed deprecation with Symfony 4.2 - Upgraded phpunit bridge requirement * resolve phpunit versions * fix TreeBuilder not having ctor in < sf 4.1 Co-authored-by: Jo Carter * move php stan to allowed failures untill https://github.com/phpstan/phpstan/issues/1482 is fixed --- .travis.yml | 14 +++++++----- composer.json | 3 +-- src/DependencyInjection/Configuration.php | 27 +++++++++++++++-------- 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index fdd3516c..8836409e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,10 @@ matrix: include: # Minimum supported dependencies with the oldest supported PHP version - php: 7.1 - env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" SYMFONY_DEPRECATIONS_HELPER="weak_vendors" + env: + - COMPOSER_FLAGS="--prefer-stable --prefer-lowest" + - SYMFONY_DEPRECATIONS_HELPER="weak_vendors" + - SYMFONY_PHPUNIT_VERSION="5.7.26" # Coverage - php: 7.1 @@ -37,16 +40,17 @@ matrix: env: TARGET=docs - php: 7.2 - env: STABILITY="dev" - - - php: 7.1 - env: TARGET=phpstan LEVEL=7 + env: + - STABILITY="dev" + - SYMFONY_PHPUNIT_VERSION="6.5" - php: '7.2' env: PHPUNIT_FLAGS="--group=proxy" allow_failures: - env: PHPUNIT_FLAGS="--group=proxy" + - php: 7.1 + env: TARGET=phpstan LEVEL=7 before_install: - if ! [ -z "$STABILITY" ]; then composer config minimum-stability ${STABILITY}; fi; diff --git a/composer.json b/composer.json index fff522fd..e3d6db05 100644 --- a/composer.json +++ b/composer.json @@ -42,9 +42,8 @@ "friendsofphp/php-cs-fixer": "^2.0", "matthiasnoback/symfony-dependency-injection-test": "^1.0 || ^2.0", "phpunit/phpunit": "^6.0", - "sensio/distribution-bundle": "^3.0.12 || ^4.0 || ^5.0", "symfony/console": "^3.4 || ^4.0", - "symfony/phpunit-bridge": "^4.0", + "symfony/phpunit-bridge": "^4.1", "symfony/yaml": "^3.4 || ^4.0" }, "suggest": { diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index c7a9bb7f..47afaeb7 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -23,9 +23,16 @@ final class Configuration implements ConfigurationInterface { public function getConfigTreeBuilder(): TreeBuilder { - $treeBuilder = $this->createTreeBuilder(); - $treeBuilder - ->root('fos_ck_editor') + if (\method_exists(TreeBuilder::class, 'getRootNode')) { + $treeBuilder = new TreeBuilder('fos_ck_editor'); + $rootNode = $treeBuilder->getRootNode(); + } else { + // BC layer for symfony/config 4.1 and older + $treeBuilder = new TreeBuilder(); + $rootNode = $treeBuilder->root('fos_ck_editor'); + } + + $rootNode ->children() ->booleanNode('enable')->defaultTrue()->end() ->booleanNode('async')->defaultFalse()->end() @@ -151,15 +158,17 @@ private function createPrototypeNode(string $name): ArrayNodeDefinition private function createNode(string $name): ArrayNodeDefinition { - $node = $this->createTreeBuilder()->root($name); + if (\method_exists(TreeBuilder::class, 'getRootNode')) { + $treeBuilder = new TreeBuilder($name); + $node = $treeBuilder->getRootNode(); + } else { + // BC layer for symfony/config 4.1 and older + $treeBuilder = new TreeBuilder(); + $node = $treeBuilder->root($name); + } \assert($node instanceof ArrayNodeDefinition); return $node; } - - private function createTreeBuilder(): TreeBuilder - { - return new TreeBuilder(); - } }