Skip to content

Commit 91c5129

Browse files
committed
drop Symfony 3
1 parent 5475b5e commit 91c5129

9 files changed

+61
-56
lines changed

.php_cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ $finder = PhpCsFixer\Finder::create()
66
;
77

88
return PhpCsFixer\Config::create()
9+
->setRiskyAllowed(true)
910
->setRules([
1011
'@Symfony' => true,
11-
'array_syntax' => ['syntax' => 'short'],
12-
'ordered_imports' => true,
12+
'@Symfony:risky' => true,
13+
'@PHP71Migration:risky' => true,
1314
])
1415
->setFinder($finder)
1516
;

.travis.yml

+3-11
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,19 @@
11
language: php
22

3-
php:
4-
- 7.1
5-
- 7.2
6-
- 7.3
7-
- 7.4
8-
- nightly
9-
103
cache:
114
directories:
125
- $HOME/.composer/cache
136

14-
matrix:
7+
jobs:
158
fast_finish: true
169
include:
1710
- php: 7.1
1811
env: SYMFONY_VERSION=3.4.* SYMFONY_DEPRECATIONS_HELPER=strict COMPOSER_FLAGS="--prefer-lowest"
1912
- php: 7.3
2013
env: SYMFONY_VERSION=4.4.*
2114
- php: 7.4
22-
env: SYMFONY_VERSION=5.0.* DEPENDENCIES=dev COMPOSER_FLAGS="--prefer-stable"
23-
allow_failures:
24-
- php: nightly
15+
env: SYMFONY_VERSION=5.2.* DEPENDENCIES=dev COMPOSER_FLAGS="--prefer-stable"
16+
- php: 8.0
2517

2618
env:
2719
global:

composer.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@
1414
"require": {
1515
"php": "^7.1",
1616
"opensoft/doctrine-postgres-types": "^1.3",
17-
"symfony/config": "^3.4 || ^4.3 || ^5.0",
18-
"symfony/dependency-injection": "^3.4 || ^4.3 || ^5.0",
19-
"symfony/http-kernel": "^3.4 || ^4.3 || ^5.0"
17+
"symfony/config": "^4.4 || ^5.0",
18+
"symfony/dependency-injection": "^4.4 || ^5.0",
19+
"symfony/http-kernel": "^4.4 || ^5.0"
2020
},
2121
"require-dev":{
22+
"dg/bypass-finals": "^1.3",
2223
"phpunit/phpunit": "^7.5 || ^8.5"
2324
},
2425
"autoload": {

phpunit.xml.dist

+4
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,8 @@
1212
<directory>./src</directory>
1313
</whitelist>
1414
</filter>
15+
<!-- see https://www.tomasvotruba.cz/blog/2019/03/28/how-to-mock-final-classes-in-phpunit/ -->
16+
<extensions>
17+
<extension class="Garak\DoctrinePostgresTypesBundle\Tests\BypassFinalHook"/>
18+
</extensions>
1519
</phpunit>

src/DependencyInjection/DoctrinePostgresTypesExtension.php

+15-18
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,32 @@
22

33
namespace Garak\DoctrinePostgresTypesBundle\DependencyInjection;
44

5+
use Doctrine\DBAL\PostgresTypes\InetType;
6+
use Doctrine\DBAL\PostgresTypes\IntArrayType;
7+
use Doctrine\DBAL\PostgresTypes\TextArrayType;
8+
use Doctrine\DBAL\PostgresTypes\TsqueryType;
9+
use Doctrine\DBAL\PostgresTypes\TsvectorType;
10+
use Doctrine\DBAL\PostgresTypes\XmlType;
511
use Symfony\Component\DependencyInjection\ContainerBuilder;
612
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
713
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
814

9-
/**
10-
* DoctrinePostgresTypesExtension.
11-
*/
12-
class DoctrinePostgresTypesExtension extends Extension implements PrependExtensionInterface
15+
final class DoctrinePostgresTypesExtension extends Extension implements PrependExtensionInterface
1316
{
14-
/**
15-
* {@inheritdoc}
16-
*/
17-
public function load(array $configs, ContainerBuilder $container)
17+
public function load(array $configs, ContainerBuilder $container): void
1818
{
1919
}
2020

21-
/**
22-
* {@inheritdoc}
23-
*/
24-
public function prepend(ContainerBuilder $container)
21+
public function prepend(ContainerBuilder $container): void
2522
{
2623
$config = [
2724
'dbal' => ['types' => [
28-
'text_array' => 'Doctrine\DBAL\PostgresTypes\TextArrayType',
29-
'int_array' => 'Doctrine\DBAL\PostgresTypes\IntArrayType',
30-
'tsvector' => 'Doctrine\DBAL\PostgresTypes\TsvectorType',
31-
'tsquery' => 'Doctrine\DBAL\PostgresTypes\TsqueryType',
32-
'xml' => 'Doctrine\DBAL\PostgresTypes\XmlType',
33-
'inet' => 'Doctrine\DBAL\PostgresTypes\InetType',
25+
'text_array' => TextArrayType::class,
26+
'int_array' => IntArrayType::class,
27+
'tsvector' => TsvectorType::class,
28+
'tsquery' => TsqueryType::class,
29+
'xml' => XmlType::class,
30+
'inet' => InetType::class,
3431
]],
3532
];
3633
$container->prependExtensionConfig('doctrine', $config);

src/DoctrinePostgresTypesBundle.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44

55
use Symfony\Component\HttpKernel\Bundle\Bundle;
66

7-
class DoctrinePostgresTypesBundle extends Bundle
7+
final class DoctrinePostgresTypesBundle extends Bundle
88
{
99
}

tests/BypassFinalHook.php

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace Garak\DoctrinePostgresTypesBundle\Tests;
4+
5+
use DG\BypassFinals;
6+
use PHPUnit\Runner\BeforeTestHook;
7+
8+
final class BypassFinalHook implements BeforeTestHook
9+
{
10+
public function executeBeforeTest(string $test): void
11+
{
12+
BypassFinals::enable();
13+
}
14+
}
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,45 @@
11
<?php
22

3-
namespace Garak\DoctrinePostgresTypes\Tests\DependencyInjection;
3+
namespace Garak\DoctrinePostgresTypesBundle\Tests\DependencyInjection;
44

55
use Garak\DoctrinePostgresTypesBundle\DependencyInjection\DoctrinePostgresTypesExtension;
66
use PHPUnit\Framework\TestCase;
77
use Symfony\Component\DependencyInjection\ContainerBuilder;
88
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
99

10-
class DoctrinePostgresTypesExtensionTest extends TestCase
10+
final class DoctrinePostgresTypesExtensionTest extends TestCase
1111
{
12-
public function testLoadFailure()
12+
public function testLoadFailure(): void
1313
{
14-
$container = $this->getMockBuilder(ContainerBuilder::class)
15-
->disableOriginalConstructor()->getMock();
14+
$container = $this->createMock(ContainerBuilder::class);
1615
$extension = $this->createMock(DoctrinePostgresTypesExtension::class);
1716

1817
$extension->load([[]], $container);
19-
$this->assertFalse(false);
18+
self::assertFalse(false);
2019
}
2120

22-
public function testLoadSetParameters()
21+
public function testLoadSetParameters(): void
2322
{
24-
$container = $this->getMockBuilder(ContainerBuilder::class)
25-
->disableOriginalConstructor()->getMock();
23+
$container = $this->createMock(ContainerBuilder::class);
2624
$parameterBag = $this->getMockBuilder(ParameterBag::class)
2725
->disableOriginalConstructor()->getMock();
2826

29-
$parameterBag->expects($this->any())->method('add');
30-
31-
$container->expects($this->any())->method('getParameterBag')->will($this->returnValue($parameterBag));
27+
$parameterBag->method('add');
28+
$container->method('getParameterBag')->willReturn($parameterBag);
3229

3330
$extension = new DoctrinePostgresTypesExtension();
3431
$configs = [];
3532
$extension->load($configs, $container);
36-
$this->assertTrue(true);
33+
self::assertTrue(true);
3734
}
3835

39-
public function testPrepend()
36+
public function testPrepend(): void
4037
{
41-
$container = $this->getMockBuilder(ContainerBuilder::class)
42-
->disableOriginalConstructor()->getMock();
43-
$container->expects($this->once())->method('prependExtensionConfig');
38+
$container = $this->createMock(ContainerBuilder::class);
39+
$container->expects(self::once())->method('prependExtensionConfig');
4440

4541
$extension = new DoctrinePostgresTypesExtension();
4642
$extension->prepend($container);
47-
$this->assertTrue(true);
43+
self::assertTrue(true);
4844
}
4945
}

tests/DoctrinePostgresTypesBundleTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
use Garak\DoctrinePostgresTypesBundle\DoctrinePostgresTypesBundle;
66
use PHPUnit\Framework\TestCase;
77

8-
class DoctrinePostgresTypesBundleTest extends TestCase
8+
final class DoctrinePostgresTypesBundleTest extends TestCase
99
{
10-
public function testConstruct()
10+
public function testConstruct(): void
1111
{
1212
$bundle = new DoctrinePostgresTypesBundle();
13-
$this->assertInstanceOf(DoctrinePostgresTypesBundle::class, $bundle);
13+
self::assertInstanceOf(DoctrinePostgresTypesBundle::class, $bundle);
1414
}
1515
}

0 commit comments

Comments
 (0)