Skip to content

Commit 2afd624

Browse files
committed
improvements
1 parent b4133cb commit 2afd624

File tree

76 files changed

+515
-486
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+515
-486
lines changed

.github/workflows/php-cs-fixer.yml

-23
This file was deleted.

.github/workflows/pint.yml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Check & fix styling
2+
3+
on: [push]
4+
5+
jobs:
6+
pint:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- name: Checkout code
11+
uses: actions/checkout@v3
12+
with:
13+
ref: ${{ github.head_ref }}
14+
15+
- name: Fix PHP code style issues
16+
uses: aglipanci/[email protected]
17+
18+
- name: Commit changes
19+
uses: stefanzweifel/git-auto-commit-action@v4
20+
with:
21+
commit_message: Fix PHP styling

.gitignore

-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
.idea
2-
.php_cs
3-
.php_cs.cache
42
.phpunit.result.cache
53
build
64
composer.lock
@@ -10,5 +8,3 @@ phpunit.xml
108
phpstan.neon
119
testbench.yaml
1210
vendor
13-
node_modules
14-
.php-cs-fixer.cache

.php-cs-fixer.dist.php

-40
This file was deleted.

composer.json

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
},
2323
"require-dev": {
2424
"doctrine/dbal": "^3.2",
25+
"laravel/pint": "^1.2",
2526
"nunomaduro/collision": "^6.0|^5.10",
2627
"nunomaduro/larastan": "^1.0",
2728
"orchestra/testbench": "^7.0|^6.24",
@@ -31,6 +32,7 @@
3132
"phpstan/phpstan-deprecation-rules": "^1.0",
3233
"phpstan/phpstan-phpunit": "^1.0",
3334
"phpunit/phpunit": "^9.5",
35+
"rector/rector": "^0.14.2",
3436
"spatie/laravel-ray": "^1.26"
3537
},
3638
"autoload": {

config/cockroachdb-laravel.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
// config for YlsIdeas/CockroachDb
34
return [
45

database.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<?php
22

33
$host = '127.0.0.1';
4-
$db = 'default';
4+
$db = 'default';
55
$user = 'root';
66
$pass = '';
77

88
$options = [
9-
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
9+
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
1010
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
11-
PDO::ATTR_EMULATE_PREPARES => false,
11+
PDO::ATTR_EMULATE_PREPARES => false,
1212
];
1313

1414
$dsn = "pgsql:host=$host;port=26257;dbname=$db";

pint.json

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"preset": "psr12",
3+
"rules": {
4+
"array_syntax": {
5+
"syntax": "short"
6+
},
7+
"ordered_imports": {
8+
"sort_algorithm": "alpha"
9+
},
10+
"no_unused_imports": true,
11+
"not_operator_with_successor_space": true,
12+
"trailing_comma_in_multiline": true,
13+
"phpdoc_scalar": true,
14+
"unary_operator_spaces": true,
15+
"binary_operator_spaces": true,
16+
"blank_line_before_statement": {
17+
"statements": [
18+
"break",
19+
"continue",
20+
"declare",
21+
"return",
22+
"throw",
23+
"try"
24+
]
25+
},
26+
"phpdoc_single_line_var_spacing": true,
27+
"phpdoc_var_without_name": true,
28+
"class_attributes_separation": {
29+
"elements": {
30+
"method": "one"
31+
}
32+
},
33+
"method_argument_space": {
34+
"on_multiline": "ensure_fully_multiline",
35+
"keep_multiple_spaces_after_comma": true
36+
},
37+
"single_trait_insert_per_statement": true,
38+
"php_unit_method_casing": {
39+
"case": "snake_case"
40+
}
41+
}
42+
}

rector.php

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
6+
use Rector\Config\RectorConfig;
7+
use Rector\Set\ValueObject\LevelSetList;
8+
9+
return static function (RectorConfig $rectorConfig): void {
10+
$rectorConfig->paths([
11+
__DIR__ . '/src',
12+
__DIR__ . '/tests',
13+
]);
14+
15+
// register a single rule
16+
$rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class);
17+
$rectorConfig->rules([
18+
\Rector\PHPUnit\Rector\Class_\AddSeeTestAnnotationRector::class,
19+
\Rector\PHPUnit\Rector\ClassMethod\ReplaceTestAnnotationWithPrefixedFunctionRector::class,
20+
]);
21+
22+
// define sets of rules
23+
$rectorConfig->sets([
24+
LevelSetList::UP_TO_PHP_80,
25+
\Rector\Set\ValueObject\SetList::PHP_80,
26+
\Rector\PHPUnit\Set\PHPUnitLevelSetList::UP_TO_PHPUNIT_90,
27+
\Rector\PHPUnit\Set\PHPUnitSetList::PHPUNIT_90,
28+
29+
]);
30+
};

tests/Database/DatabaseCockroachDbBuilderTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ protected function tearDown(): void
1515
m::close();
1616
}
1717

18-
public function testCreateDatabase()
18+
public function test_create_database()
1919
{
2020
$grammar = new CockroachGrammar();
2121

@@ -30,7 +30,7 @@ public function testCreateDatabase()
3030
$builder->createDatabase('my_temporary_database');
3131
}
3232

33-
public function testDropDatabaseIfExists()
33+
public function test_drop_database_if_exists()
3434
{
3535
$grammar = new CockroachGrammar();
3636

tests/Database/DatabaseCockroachDbProcessorTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
class DatabaseCockroachDbProcessorTest extends TestCase
99
{
10-
public function testProcessColumnListing()
10+
public function test_process_column_listing()
1111
{
1212
$processor = new CockroachDbProcessor();
1313

tests/Database/DatabaseCockroachDbQueryBuilderTest.php

+10-10
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ protected function tearDown(): void
2020
m::close();
2121
}
2222

23-
public function testWhereTimeOperatorOptional()
23+
public function test_where_time_operator_optional()
2424
{
2525
$builder = $this->getCockroachDbBuilder();
2626
$builder->select('*')->from('users')->whereTime('created_at', '22:00');
2727
$this->assertSame('select * from "users" where "created_at"::time = ?', $builder->toSql());
2828
$this->assertEquals([0 => '22:00'], $builder->getBindings());
2929
}
3030

31-
public function testWhereDate()
31+
public function test_where_date()
3232
{
3333
$builder = $this->getCockroachDbBuilder();
3434
$builder->select('*')->from('users')->whereDate('created_at', '=', '2015-12-21');
@@ -40,39 +40,39 @@ public function testWhereDate()
4040
$this->assertSame('select * from "users" where "created_at"::date = NOW()', $builder->toSql());
4141
}
4242

43-
public function testWhereDay()
43+
public function test_where_day()
4444
{
4545
$builder = $this->getCockroachDbBuilder();
4646
$builder->select('*')->from('users')->whereDay('created_at', '=', 1);
4747
$this->assertSame('select * from "users" where extract(day from "created_at") = ?', $builder->toSql());
4848
$this->assertEquals([0 => 1], $builder->getBindings());
4949
}
5050

51-
public function testWhereMonth()
51+
public function test_where_month()
5252
{
5353
$builder = $this->getCockroachDbBuilder();
5454
$builder->select('*')->from('users')->whereMonth('created_at', '=', 5);
5555
$this->assertSame('select * from "users" where extract(month from "created_at") = ?', $builder->toSql());
5656
$this->assertEquals([0 => 5], $builder->getBindings());
5757
}
5858

59-
public function testWhereYear()
59+
public function test_where_year()
6060
{
6161
$builder = $this->getCockroachDbBuilder();
6262
$builder->select('*')->from('users')->whereYear('created_at', '=', 2014);
6363
$this->assertSame('select * from "users" where extract(year from "created_at") = ?', $builder->toSql());
6464
$this->assertEquals([0 => 2014], $builder->getBindings());
6565
}
6666

67-
public function testWhereTime()
67+
public function test_where_time()
6868
{
6969
$builder = $this->getCockroachDbBuilder();
7070
$builder->select('*')->from('users')->whereTime('created_at', '>=', '22:00');
7171
$this->assertSame('select * from "users" where "created_at"::time >= ?', $builder->toSql());
7272
$this->assertEquals([0 => '22:00'], $builder->getBindings());
7373
}
7474

75-
public function testWhereLike()
75+
public function test_where_like()
7676
{
7777
$builder = $this->getCockroachDbBuilder();
7878
$builder->select('*')->from('users')->where('id', 'like', '1');
@@ -100,7 +100,7 @@ public function testWhereLike()
100100
$this->assertEquals([0 => '1'], $builder->getBindings());
101101
}
102102

103-
public function testUpdateMethodWithJoins()
103+
public function test_update_method_with_joins()
104104
{
105105
$builder = $this->getCockroachDbBuilder();
106106
$builder->getConnection()
@@ -115,15 +115,15 @@ public function testUpdateMethodWithJoins()
115115
$this->assertEquals(1, $result);
116116
}
117117

118-
public function testDeletesWithJoinsThrowAnException()
118+
public function test_deletes_with_joins_throw_an_exception()
119119
{
120120
$this->expectException(FeatureNotSupportedException::class);
121121
$builder = $this->getCockroachDbBuilder();
122122
$builder->from('users')->join('blocklist', 'email', '=', 'email')->delete();
123123
$builder->toSql();
124124
}
125125

126-
public function testWhereFullTextThrowsExceptionCockroachDb()
126+
public function test_where_full_text_throws_exception_cockroach_db()
127127
{
128128
if (! method_exists(Grammar::class, 'whereFulltext')) {
129129
$this->markTestSkipped('fullText features do not exist in this application version');

0 commit comments

Comments
 (0)