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

Lines changed: 0 additions & 23 deletions
This file was deleted.

.github/workflows/pint.yml

Lines changed: 21 additions & 0 deletions
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

Lines changed: 0 additions & 4 deletions
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

Lines changed: 0 additions & 40 deletions
This file was deleted.

composer.json

Lines changed: 2 additions & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 42 additions & 0 deletions
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

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 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

Lines changed: 2 additions & 2 deletions
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

0 commit comments

Comments
 (0)