Skip to content

Commit 3a5dd29

Browse files
authored
Merge pull request #132 from Sysix/php-cs-fixer
PHP CS fixer
2 parents cc366b1 + eabc2bc commit 3a5dd29

Some content is hidden

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

58 files changed

+358
-153
lines changed

.gitattributes

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
/.gitattributes export-ignore
44
/.gitignore export-ignore
55
/phpunit.xml export-ignore
6-
/phpstan.neon export-ignore
6+
/phpstan.neon export-ignore
7+
/.php-cs-fixer.dist.php export-ignore

.github/workflows/codestyle.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Run PHP-CS-Fixer
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- uses: actions/checkout@v4
11+
12+
- uses: actions/cache@v3
13+
with:
14+
path: .php-cs-fixer.cache
15+
key: ${{ runner.OS }}-${{ github.repository }}-phpcsfixer-${{ github.sha }}
16+
restore-keys: |
17+
${{ runner.OS }}-${{ github.repository }}-phpcsfixer-
18+
19+
- uses: docker://oskarstark/php-cs-fixer-ga
20+
with:
21+
args: --diff --dry-run

.github/workflows/phpstan.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Run Shepherd
1+
name: Run PHPStan
22

33
on: [pull_request]
44

.gitignore

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/tests/cache/
22

3-
# Created by https://www.toptal.com/developers/gitignore/api/windows,macos,linux,composer,phpunit,phpstorm+all,visualstudiocode
4-
# Edit at https://www.toptal.com/developers/gitignore?templates=windows,macos,linux,composer,phpunit,phpstorm+all,visualstudiocode
3+
# Created by https://www.toptal.com/developers/gitignore/api/windows,macos,linux,composer,phpunit,phpstorm+all,visualstudiocode,php-cs-fixer
4+
# Edit at https://www.toptal.com/developers/gitignore?templates=windows,macos,linux,composer,phpunit,phpstorm+all,visualstudiocode,php-cs-fixer
55

66
### Composer ###
77
composer.phar
@@ -59,6 +59,16 @@ Temporary Items
5959
# iCloud generated files
6060
*.icloud
6161

62+
### PHP-CS-Fixer ###
63+
# Covers PHP CS Fixer
64+
# Reference: https://cs.symfony.com/
65+
66+
# Generated files
67+
.php-cs-fixer.cache
68+
69+
# Local config See: https://cs.symfony.com/doc/config.html
70+
.php-cs-fixer.php
71+
6272
### PhpStorm+all ###
6373
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
6474
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
@@ -207,4 +217,4 @@ $RECYCLE.BIN/
207217
# Windows shortcuts
208218
*.lnk
209219

210-
# End of https://www.toptal.com/developers/gitignore/api/windows,macos,linux,composer,phpunit,phpstorm+all,visualstudiocode
220+
# End of https://www.toptal.com/developers/gitignore/api/windows,macos,linux,composer,phpunit,phpstorm+all,visualstudiocode,php-cs-fixer

.php-cs-fixer.dist.php

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
<?php declare(strict_types=1);
2+
3+
$finder = PhpCsFixer\Finder::create()
4+
->files()
5+
->in(__DIR__ . '/src')
6+
->in(__DIR__ . '/tests');
7+
8+
return (new PhpCsFixer\Config())
9+
->setFinder($finder)
10+
->setRiskyAllowed(true)
11+
->setRules([
12+
'@PSR12' => true,
13+
'modernize_types_casting' => true,
14+
'multiline_comment_opening_closing' => true,
15+
'multiline_whitespace_before_semicolons' => true,
16+
'native_type_declaration_casing' => true,
17+
'no_alias_functions' => true,
18+
'no_alias_language_construct_call' => true,
19+
'no_alternative_syntax' => true,
20+
'no_binary_string' => true,
21+
'no_blank_lines_after_phpdoc' => true,
22+
'no_empty_comment' => true,
23+
'no_empty_statement' => true,
24+
'no_extra_blank_lines' => true,
25+
'no_homoglyph_names' => true,
26+
'no_leading_namespace_whitespace' => true,
27+
'no_multiline_whitespace_around_double_arrow' => true,
28+
'no_null_property_initialization' => true,
29+
'no_short_bool_cast' => true,
30+
'no_singleline_whitespace_before_semicolons' => true,
31+
'no_spaces_around_offset' => true,
32+
'no_superfluous_elseif' => true,
33+
'no_superfluous_phpdoc_tags' => [
34+
'allow_mixed' => true,
35+
],
36+
'no_trailing_comma_in_singleline' => true,
37+
'no_trailing_whitespace_in_string' => true,
38+
'no_unneeded_braces' => true,
39+
'no_unneeded_control_parentheses' => true,
40+
'no_unneeded_import_alias' => true,
41+
'no_unset_cast' => true,
42+
'no_unset_on_property' => true,
43+
'no_unused_imports' => true,
44+
'no_useless_concat_operator' => true,
45+
'no_useless_else' => true,
46+
'no_useless_nullsafe_operator' => true,
47+
'no_useless_return' => true,
48+
'no_whitespace_before_comma_in_array' => true,
49+
'non_printable_character' => true,
50+
'normalize_index_brace' => true,
51+
'php_unit_set_up_tear_down_visibility' => true,
52+
'php_unit_test_case_static_method_calls' => [
53+
'call_type' => 'this',
54+
],
55+
'phpdoc_add_missing_param_annotation' => false,
56+
'phpdoc_align' => true,
57+
'phpdoc_annotation_without_dot' => true,
58+
'phpdoc_indent' => true,
59+
'phpdoc_inline_tag_normalizer' => true,
60+
'phpdoc_no_access' => true,
61+
'phpdoc_no_alias_tag' => true,
62+
'phpdoc_no_empty_return' => true,
63+
'phpdoc_no_package' => true,
64+
'phpdoc_no_useless_inheritdoc' => true,
65+
'phpdoc_order' => true,
66+
'phpdoc_order_by_value' => [
67+
'annotations' => [
68+
'covers',
69+
'dataProvider',
70+
'throws',
71+
'uses',
72+
],
73+
],
74+
'phpdoc_param_order' => true,
75+
'phpdoc_return_self_reference' => true,
76+
'phpdoc_scalar' => true,
77+
'phpdoc_separation' => true,
78+
'phpdoc_single_line_var_spacing' => true,
79+
'phpdoc_summary' => true,
80+
'phpdoc_tag_casing' => true,
81+
'phpdoc_tag_type' => true,
82+
'phpdoc_to_comment' => false,
83+
'phpdoc_trim' => true,
84+
'simplified_null_return' => true,
85+
'single_line_comment_spacing' => true,
86+
'single_quote' => true,
87+
'single_space_around_construct' => true,
88+
'space_after_semicolon' => true,
89+
'standardize_increment' => true,
90+
'standardize_not_equals' => true,
91+
'static_lambda' => true,
92+
'strict_param' => true,
93+
'string_length_to_empty'=> true,
94+
'string_line_ending' => true,
95+
'switch_continue_to_break' => true,
96+
'trim_array_spaces' => true,
97+
'whitespace_after_comma_in_array' => true,
98+
])
99+
->setLineEnding("\n");

composer.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
"description": "Simple API Integration for Lexoffice",
55
"scripts": {
66
"test": "phpunit",
7-
"lint": "phpstan analyse --ansi --error-format raw"
7+
"lint": "phpstan analyse --ansi --error-format raw",
8+
"codestyle:check": "php-cs-fixer check",
9+
"codestyle:fix": "php-cs-fixer fix"
810
},
911
"keywords": [
1012
"lex-office",
@@ -22,7 +24,8 @@
2224
"require-dev": {
2325
"phpstan/phpstan": "^1.10",
2426
"phpunit/phpunit": "^10.4",
25-
"guzzlehttp/guzzle": "^7.8"
27+
"guzzlehttp/guzzle": "^7.8",
28+
"friendsofphp/php-cs-fixer": "^3.41"
2629
},
2730
"suggest": {
2831
"guzzlehttp/guzzle": "^7.0",

src/Api.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
3+
declare(strict_types=1);
24

35
namespace Sysix\LexOffice;
46

@@ -34,12 +36,10 @@ class Api
3436

3537
public RequestInterface $request;
3638

37-
3839
public function __construct(
39-
#[SensitiveParameter] protected string $apiKey,
40+
#[SensitiveParameter] protected string $apiKey,
4041
protected ClientInterface $client
41-
)
42-
{
42+
) {
4343
}
4444

4545
/**
@@ -60,8 +60,7 @@ public function setRequest(RequestInterface $request): self
6060
->withHeader('Authorization', 'Bearer ' . $this->apiKey)
6161
->withHeader('Accept', 'application/json');
6262

63-
64-
if (!$request->hasHeader('Content-Type') && in_array($request->getMethod(), ['POST', 'PUT'])) {
63+
if (!$request->hasHeader('Content-Type') && in_array($request->getMethod(), ['POST', 'PUT'], true)) {
6564
$request = $request->withHeader('Content-Type', 'application/json');
6665
}
6766

src/BaseClient.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
<?php declare(strict_types=1);
1+
<?php
22

3+
declare(strict_types=1);
34

45
namespace Sysix\LexOffice;
56

@@ -11,8 +12,7 @@ abstract class BaseClient implements ClientInterface
1112

1213
public function __construct(
1314
protected Api $api
14-
)
15-
{
15+
) {
1616
}
1717

1818
/**

src/ClientInterface.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
3+
declare(strict_types=1);
24

35
namespace Sysix\LexOffice;
46

src/Clients/Contact.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
3+
declare(strict_types=1);
24

35
namespace Sysix\LexOffice\Clients;
46

@@ -15,7 +17,6 @@ class Contact extends PaginationClient
1517

1618
protected string $resource = 'contacts';
1719

18-
1920
public ?int $number = null;
2021

2122
public ?bool $customer = null;
@@ -30,4 +31,4 @@ protected function buildQueryParams(array $params): string
3031

3132
return parent::buildQueryParams($params);
3233
}
33-
}
34+
}

0 commit comments

Comments
 (0)