Skip to content

Commit 095b91e

Browse files
committed
Format code with PHP-CS-Fixer
1 parent e3fa0d8 commit 095b91e

12 files changed

Lines changed: 79 additions & 13 deletions

File tree

.github/workflows/php.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,7 @@ jobs:
5555
run: composer test-without-mssql
5656
env:
5757
POSTGRES_HOST: localhost
58+
59+
- name: Check Formatting
60+
run: vendor/bin/php-cs-fixer fix -v --dry-run --stop-on-violation --using-cache=no
61+
if: ${{ matrix.php == '8.3' }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.idea
22
.phpunit.result.cache
3+
.php-cs-fixer.cache
34

45
/vendor/
56
/composer.lock

.php-cs-fixer.php

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
3+
$finder = PhpCsFixer\Finder::create()
4+
->path([
5+
'lib/',
6+
'test/',
7+
])
8+
->ignoreVCSIgnored(true)
9+
->append([__FILE__])
10+
->in(__DIR__);
11+
12+
$config = new PhpCsFixer\Config();
13+
return $config
14+
->setRules([
15+
'@PER-CS' => true,
16+
'align_multiline_comment' => true,
17+
'array_syntax' => true,
18+
'binary_operator_spaces' => true,
19+
'class_attributes_separation' => ['elements' => ['method' => 'one']],
20+
'class_reference_name_casing' => true,
21+
'clean_namespace' => true,
22+
'combine_consecutive_unsets' => true,
23+
'declare_parentheses' => true,
24+
'integer_literal_case' => true,
25+
'lambda_not_used_import' => true,
26+
'linebreak_after_opening_tag' => true,
27+
'method_chaining_indentation' => true,
28+
'multiline_comment_opening_closing' => true,
29+
'native_function_casing' => true,
30+
'no_alternative_syntax' => true,
31+
'no_blank_lines_after_phpdoc' => true,
32+
'no_empty_comment' => true,
33+
'no_empty_phpdoc' => true,
34+
'no_empty_statement' => true,
35+
'no_extra_blank_lines' => true,
36+
'no_spaces_around_offset' => true,
37+
'no_superfluous_phpdoc_tags' => true,
38+
'no_unneeded_control_parentheses' => true,
39+
'no_unused_imports' => true,
40+
'no_useless_return' => true,
41+
'no_whitespace_before_comma_in_array' => true,
42+
'object_operator_without_whitespace' => true,
43+
'ordered_imports' => ['sort_algorithm' => 'alpha'],
44+
'phpdoc_indent' => true,
45+
'phpdoc_no_empty_return' => true,
46+
'phpdoc_single_line_var_spacing' => true,
47+
'return_assignment' => true,
48+
'semicolon_after_instruction' => true,
49+
'single_class_element_per_statement' => true,
50+
'single_space_around_construct' => true,
51+
'space_after_semicolon' => true,
52+
'standardize_not_equals' => true,
53+
'trim_array_spaces' => true,
54+
'type_declaration_spaces' => true,
55+
'types_spaces' => true,
56+
'whitespace_after_comma_in_array' => ['ensure_single_space' => true],
57+
])
58+
->setFinder($finder);

composer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"ext-pdo": "*"
2121
},
2222
"require-dev": {
23+
"friendsofphp/php-cs-fixer": "^3.64",
2324
"phpunit/phpunit": "^10.5",
2425
"psalm/plugin-phpunit": "^0.19",
2526
"ramsey/uuid": "^4.2.3",
@@ -40,6 +41,7 @@
4041
},
4142
"scripts": {
4243
"analyze": "psalm",
44+
"cs-fix": "php-cs-fixer fix -v",
4345
"test": "phpunit",
4446
"test-mssql": "phpunit --exclude-group mysql,pgsql",
4547
"test-mysql": "phpunit --exclude-group mssql,pgsql",

lib/BulkInsertResult.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ class BulkInsertResult
1717
public function __construct(
1818
public readonly array $ids,
1919
public readonly int $affected,
20-
public readonly int $queryCount = 1
20+
public readonly int $queryCount = 1,
2121
) {}
2222
}

lib/InsertResult.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ class InsertResult
1515
*/
1616
public function __construct(
1717
public readonly int $id,
18-
public readonly int $affected
18+
public readonly int $affected,
1919
) {}
2020
}

lib/QueryBuilder/Insert.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public static function batchRows(array $colVals, int $maxBoundParams, int $maxRo
2424
}
2525

2626
if ($maxBoundParams > 0) {
27-
$maxRowsPerQuery = (int)floor($maxBoundParams / count($colVals[0])); // max bound params divided by params per row
27+
$maxRowsPerQuery = (int) floor($maxBoundParams / count($colVals[0])); // max bound params divided by params per row
2828
}
2929

3030
if ($maxRows > 0 && $maxRowsPerQuery > $maxRows) {

lib/SqlException.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ class SqlException extends \RuntimeException
1414
*/
1515
private readonly string $sqlState;
1616

17-
public function __construct(string $message, int $code, string $details, string $sqlState) {
17+
public function __construct(string $message, int $code, string $details, string $sqlState)
18+
{
1819
if ($details !== '') {
1920
$message .= ": $details";
2021
}

test/DbTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
namespace PeachySQL\Test;
66

7-
use PeachySQL\{PeachySql, SqlException};
87
use PeachySQL\QueryBuilder\SqlParams;
8+
use PeachySQL\{PeachySql, SqlException};
99
use PHPUnit\Framework\TestCase;
1010
use Ramsey\Uuid\Uuid;
1111

test/QueryBuilder/InsertTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,19 @@ public static function batchRowsTestCases(): array
2121
$colVals = [
2222
[
2323
'column1' => 'test',
24-
'column2' => 'test2'
24+
'column2' => 'test2',
2525
],
2626
[
2727
'column1' => 'test3',
28-
'column2' => 'test4'
28+
'column2' => 'test4',
2929
],
3030
[
3131
'column1' => 'test5',
32-
'column2' => 'test6'
32+
'column2' => 'test6',
3333
],
3434
[
3535
'column1' => 'test7',
36-
'column2' => 'test8'
36+
'column2' => 'test8',
3737
],
3838
];
3939

0 commit comments

Comments
 (0)