Skip to content

Commit

Permalink
improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
peterfox committed Sep 22, 2022
1 parent b4133cb commit 2afd624
Show file tree
Hide file tree
Showing 76 changed files with 515 additions and 486 deletions.
23 changes: 0 additions & 23 deletions .github/workflows/php-cs-fixer.yml

This file was deleted.

21 changes: 21 additions & 0 deletions .github/workflows/pint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Check & fix styling

on: [push]

jobs:
pint:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}

- name: Fix PHP code style issues
uses: aglipanci/laravel-pint-action@1.0.0

- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Fix PHP styling
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
.idea
.php_cs
.php_cs.cache
.phpunit.result.cache
build
composer.lock
Expand All @@ -10,5 +8,3 @@ phpunit.xml
phpstan.neon
testbench.yaml
vendor
node_modules
.php-cs-fixer.cache
40 changes: 0 additions & 40 deletions .php-cs-fixer.dist.php

This file was deleted.

2 changes: 2 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
},
"require-dev": {
"doctrine/dbal": "^3.2",
"laravel/pint": "^1.2",
"nunomaduro/collision": "^6.0|^5.10",
"nunomaduro/larastan": "^1.0",
"orchestra/testbench": "^7.0|^6.24",
Expand All @@ -31,6 +32,7 @@
"phpstan/phpstan-deprecation-rules": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
"phpunit/phpunit": "^9.5",
"rector/rector": "^0.14.2",
"spatie/laravel-ray": "^1.26"
},
"autoload": {
Expand Down
1 change: 1 addition & 0 deletions config/cockroachdb-laravel.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

// config for YlsIdeas/CockroachDb
return [

Expand Down
6 changes: 3 additions & 3 deletions database.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?php

$host = '127.0.0.1';
$db = 'default';
$db = 'default';
$user = 'root';
$pass = '';

$options = [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_EMULATE_PREPARES => false,
PDO::ATTR_EMULATE_PREPARES => false,
];

$dsn = "pgsql:host=$host;port=26257;dbname=$db";
Expand Down
42 changes: 42 additions & 0 deletions pint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"preset": "psr12",
"rules": {
"array_syntax": {
"syntax": "short"
},
"ordered_imports": {
"sort_algorithm": "alpha"
},
"no_unused_imports": true,
"not_operator_with_successor_space": true,
"trailing_comma_in_multiline": true,
"phpdoc_scalar": true,
"unary_operator_spaces": true,
"binary_operator_spaces": true,
"blank_line_before_statement": {
"statements": [
"break",
"continue",
"declare",
"return",
"throw",
"try"
]
},
"phpdoc_single_line_var_spacing": true,
"phpdoc_var_without_name": true,
"class_attributes_separation": {
"elements": {
"method": "one"
}
},
"method_argument_space": {
"on_multiline": "ensure_fully_multiline",
"keep_multiple_spaces_after_comma": true
},
"single_trait_insert_per_statement": true,
"php_unit_method_casing": {
"case": "snake_case"
}
}
}
30 changes: 30 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

declare(strict_types=1);

use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
__DIR__ . '/src',
__DIR__ . '/tests',
]);

// register a single rule
$rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class);
$rectorConfig->rules([
\Rector\PHPUnit\Rector\Class_\AddSeeTestAnnotationRector::class,
\Rector\PHPUnit\Rector\ClassMethod\ReplaceTestAnnotationWithPrefixedFunctionRector::class,
]);

// define sets of rules
$rectorConfig->sets([
LevelSetList::UP_TO_PHP_80,
\Rector\Set\ValueObject\SetList::PHP_80,
\Rector\PHPUnit\Set\PHPUnitLevelSetList::UP_TO_PHPUNIT_90,
\Rector\PHPUnit\Set\PHPUnitSetList::PHPUNIT_90,

]);
};
4 changes: 2 additions & 2 deletions tests/Database/DatabaseCockroachDbBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ protected function tearDown(): void
m::close();
}

public function testCreateDatabase()
public function test_create_database()
{
$grammar = new CockroachGrammar();

Expand All @@ -30,7 +30,7 @@ public function testCreateDatabase()
$builder->createDatabase('my_temporary_database');
}

public function testDropDatabaseIfExists()
public function test_drop_database_if_exists()
{
$grammar = new CockroachGrammar();

Expand Down
2 changes: 1 addition & 1 deletion tests/Database/DatabaseCockroachDbProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class DatabaseCockroachDbProcessorTest extends TestCase
{
public function testProcessColumnListing()
public function test_process_column_listing()
{
$processor = new CockroachDbProcessor();

Expand Down
20 changes: 10 additions & 10 deletions tests/Database/DatabaseCockroachDbQueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ protected function tearDown(): void
m::close();
}

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

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

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

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

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

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

public function testWhereLike()
public function test_where_like()
{
$builder = $this->getCockroachDbBuilder();
$builder->select('*')->from('users')->where('id', 'like', '1');
Expand Down Expand Up @@ -100,7 +100,7 @@ public function testWhereLike()
$this->assertEquals([0 => '1'], $builder->getBindings());
}

public function testUpdateMethodWithJoins()
public function test_update_method_with_joins()
{
$builder = $this->getCockroachDbBuilder();
$builder->getConnection()
Expand All @@ -115,15 +115,15 @@ public function testUpdateMethodWithJoins()
$this->assertEquals(1, $result);
}

public function testDeletesWithJoinsThrowAnException()
public function test_deletes_with_joins_throw_an_exception()
{
$this->expectException(FeatureNotSupportedException::class);
$builder = $this->getCockroachDbBuilder();
$builder->from('users')->join('blocklist', 'email', '=', 'email')->delete();
$builder->toSql();
}

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

0 comments on commit 2afd624

Please sign in to comment.