Skip to content

Commit 8ef04ef

Browse files
author
Pavel Batanov
authored
Merge pull request #2 from paillechat/feature/support-symfony-5
Add support for symfony 5 and dbal 2.10
2 parents 75ed51b + 9759ab2 commit 8ef04ef

File tree

4 files changed

+25
-10
lines changed

4 files changed

+25
-10
lines changed

.travis.yml

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ matrix:
1919
env: PACKAGES='symfony/symfony=4.0.*'
2020
- php: 7.1
2121
env: PACKAGES='symfony/symfony=4.1.*'
22+
- php: 7.3
23+
env: PACKAGES='symfony/symfony=5.* doctrine/dbal=2.10'
2224

2325
before_install:
2426
- travis_retry composer self-update

composer.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
"require": {
1414
"php": "^7.1",
1515
"paillechat/php-enum": "^1.2 || ^2.1",
16-
"symfony/http-kernel": "^3.4 || ^4.0",
17-
"symfony/dependency-injection": "^3.4 || ^4.0",
18-
"symfony/config": "^3.4 || ^4.0",
16+
"symfony/http-kernel": "^3.4 || ^4.0 || ^5.0",
17+
"symfony/dependency-injection": "^3.4 || ^4.0 || ^5.0",
18+
"symfony/config": "^3.4 || ^4.0 || ^5.0",
1919
"doctrine/dbal": "^2.4"
2020
},
2121
"require-dev": {
2222
"phpunit/phpunit": "^7.0",
23-
"symfony/yaml": "^3.4 || ^4.0"
23+
"symfony/yaml": "^3.4 || ^4.0 || ^5.0"
2424
},
2525
"autoload": {
2626
"psr-4": {

src/DependencyInjection/Configuration.php

+8-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,14 @@ final class Configuration implements ConfigurationInterface
1111
/** {@inheritdoc} */
1212
public function getConfigTreeBuilder(): TreeBuilder
1313
{
14-
$builder = new TreeBuilder();
15-
16-
$root = $builder->root('lamoda_enum');
14+
$name = 'lamoda_enum';
15+
if (method_exists(TreeBuilder::class, 'root')) {
16+
$builder = new TreeBuilder();
17+
$root = $builder->root($name);
18+
} else {
19+
$builder = new TreeBuilder($name);
20+
$root = $builder->getRootNode();
21+
}
1722

1823
$root->children()->booleanNode('enum_name_type_mapping')
1924
->defaultValue(false);

tests/Unit/DBAL/EnumTypeInitializerTest.php

+11-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Doctrine\DBAL\Platforms\AbstractPlatform;
66
use Doctrine\DBAL\Types\Type;
7+
use Doctrine\DBAL\Types\TypeRegistry;
78
use Lamoda\EnumBundle\DBAL\EnumType;
89
use Lamoda\EnumBundle\DBAL\EnumTypeInitializer;
910
use Lamoda\EnumBundle\Naming\IdenticalNamingStrategy;
@@ -23,9 +24,16 @@ protected function setUp(): void
2324
{
2425
$typeReflectionClass = new \ReflectionClass(Type::class);
2526

26-
$typesMapProperty = $typeReflectionClass->getProperty('_typesMap');
27-
$typesMapProperty->setAccessible(true);
28-
$typesMapProperty->setValue([]);
27+
if ($typeReflectionClass->hasProperty('_typesMap')) {
28+
$typesMapProperty = $typeReflectionClass->getProperty('_typesMap');
29+
$typesMapProperty->setAccessible(true);
30+
$typesMapProperty->setValue([]);
31+
} else {
32+
$registry = new TypeRegistry();
33+
$typesMapProperty = $typeReflectionClass->getProperty('typeRegistry');
34+
$typesMapProperty->setAccessible(true);
35+
$typesMapProperty->setValue($registry);
36+
}
2937
}
3038

3139
public function testInitializerLoadsType(): void

0 commit comments

Comments
 (0)