Skip to content

Commit dd6e39c

Browse files
authored
Merge pull request #3 from 77web/feat/ecs
Introduced easy-coding-standard
2 parents 1d338d0 + b9832fa commit dd6e39c

File tree

5 files changed

+37
-7
lines changed

5 files changed

+37
-7
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"description": "Doctrine Type for PostgreSQL's tstzrange",
44
"type": "library",
55
"require-dev": {
6-
"phpunit/phpunit": "^10.3"
6+
"phpunit/phpunit": "^10.3",
7+
"symplify/easy-coding-standard": "^12.0"
78
},
89
"license": "MIT",
910
"autoload": {

ecs.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use PhpCsFixer\Fixer\Import\NoUnusedImportsFixer;
6+
use Symplify\EasyCodingStandard\Config\ECSConfig;
7+
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;
8+
9+
return function (ECSConfig $ecsConfig): void {
10+
$ecsConfig->paths([
11+
__DIR__ . '/src',
12+
__DIR__ . '/tests',
13+
]);
14+
15+
// this way you add a single rule
16+
$ecsConfig->rules([
17+
NoUnusedImportsFixer::class,
18+
]);
19+
20+
// this way you can add sets - group of rules
21+
$ecsConfig->sets([
22+
// run and fix, one by one
23+
// SetList::SPACES,
24+
// SetList::ARRAY,
25+
// SetList::DOCBLOCK,
26+
// SetList::NAMESPACES,
27+
// SetList::COMMENTS,
28+
SetList::PSR_12,
29+
]);
30+
};

src/TsTzRangeType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function getSQLDeclaration(array $column, AbstractPlatform $platform)
2929
public function convertToPHPValue($value, AbstractPlatform $platform)
3030
{
3131
if (!preg_match('/(\[|\()(.*)\,(.*)(\]|\))/', $value, $matches)) {
32-
throw new \RuntimeException('unexpected value from DB: '.$value);
32+
throw new \RuntimeException('unexpected value from DB: ' . $value);
3333
}
3434
$startParenthesis = $matches[1];
3535
$startsAtString = trim($matches[2], '"');

tests/Functional/TsTzRangeUsageTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,11 @@ protected function setUp(): void
2525
'driver' => 'pdo_pgsql',
2626
];
2727
$this->conn = DriverManager::getConnection($connectionParams);
28-
$this->conn->executeQuery(file_get_contents(__DIR__.'/drop_table.sql'));
29-
$this->conn->executeQuery(file_get_contents(__DIR__.'/create_table.sql'));
28+
$this->conn->executeQuery(file_get_contents(__DIR__ . '/drop_table.sql'));
29+
$this->conn->executeQuery(file_get_contents(__DIR__ . '/create_table.sql'));
3030

3131
Type::addType('tstzrange', TsTzRangeType::class);
3232
$this->conn->getDatabasePlatform()->registerDoctrineTypeMapping('tstzrange', 'tstzrange');
33-
3433
}
3534

3635
public function test_writing(): void
@@ -51,4 +50,4 @@ public function test_writing(): void
5150
$actual = $this->conn->fetchAssociative('select * from reservation');
5251
$this->assertEquals('["2023-10-01 00:00:00+09","2023-10-01 01:00:00+09")', $actual['period'], 'Period object has been converted into pgsql\'s tstzrange expression and saved successfully.');
5352
}
54-
}
53+
}

tests/TsTzRangeTypeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,4 @@ public function testConvertToDatabaseValue(): void
8787
), $platformMock);
8888
$this->assertEquals('[2023-01-01T00:00:00+09:00,2023-01-31T23:59:59+09:00)', $actual2);
8989
}
90-
}
90+
}

0 commit comments

Comments
 (0)