Skip to content

Commit 936faba

Browse files
authored
Merge pull request #82 from Art4/73-code-style-per-cs2.0
Update code style to PER-CS2.0
2 parents af94411 + eb92347 commit 936faba

File tree

87 files changed

+425
-233
lines changed

Some content is hidden

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

87 files changed

+425
-233
lines changed

.github/workflows/code-style.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Code style
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
9+
check-code-style:
10+
runs-on: ubuntu-latest
11+
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
php: ['8.2']
16+
17+
name: "Check code style | PHP ${{ matrix.php }}"
18+
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v3
22+
23+
- name: Install PHP with latest composer
24+
uses: shivammathur/setup-php@v2
25+
with:
26+
php-version: ${{ matrix.php }}
27+
ini-values: error_reporting=-1, display_errors=On, log_errors_max_len=0
28+
coverage: none
29+
tools: none
30+
31+
# Install dependencies and handle caching in one go.
32+
# @link https://github.com/marketplace/actions/install-composer-dependencies
33+
- name: "Install Composer dependencies"
34+
uses: "ramsey/composer-install@v2"
35+
36+
- name: "Check code style"
37+
run: composer run codestyle -- --dry-run

.php-cs-fixer.dist.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,13 @@
1111

1212
return (new PhpCsFixer\Config())
1313
->setRules([
14-
'@PSR12' => true,
14+
'@PER-CS2.0' => true,
15+
'@PER-CS2.0:risky' => true,
16+
'@PHP74Migration' => true,
17+
'@PHP74Migration:risky' => true,
18+
'@PHPUnit84Migration:risky' => true,
19+
'no_alias_functions' => true,
1520
])
1621
->setFinder($finder)
22+
->setRiskyAllowed(true)
1723
;

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recen
118118

119119
## :wrench: Contributing
120120

121-
Please feel free to fork and sending Pull Requests. This project follows [Semantic Versioning 2](http://semver.org) and [PSR-2](http://www.php-fig.org/psr/psr-2/).
121+
Please feel free to fork and sending Pull Requests. This project follows [Semantic Versioning 2](http://semver.org) and [PER-CS2.0](https://www.php-fig.org/per/coding-style/).
122122

123123
This projects comes with a `docker-compose.yml` where all tools for development are available.
124124

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"php": "^7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0"
1717
},
1818
"require-dev": {
19-
"friendsofphp/php-cs-fixer": "^3.2",
19+
"friendsofphp/php-cs-fixer": "^3.35",
2020
"phpstan/phpstan": "^1.10",
2121
"phpunit/phpunit": "^9 || ^10"
2222
},
@@ -31,6 +31,7 @@
3131
}
3232
},
3333
"scripts": {
34+
"codestyle": "php-cs-fixer fix --verbose --diff",
3435
"coverage": "phpunit --coverage-html=\".phpunit.cache/code-coverage\"",
3536
"phpstan": "phpstan analyze --memory-limit 512M --configuration .phpstan.neon",
3637
"phpunit": "phpunit",

src/Accessable.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
// SPDX-FileCopyrightText: 2015-2023 Artur Weigandt https://wlabs.de/kontakt
46
//
57
// SPDX-License-Identifier: GPL-3.0-or-later

src/Element.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
// SPDX-FileCopyrightText: 2015-2023 Artur Weigandt https://wlabs.de/kontakt
46
//
57
// SPDX-License-Identifier: GPL-3.0-or-later

src/Exception/AccessException.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
// SPDX-FileCopyrightText: 2015-2023 Artur Weigandt https://wlabs.de/kontakt
46
//
57
// SPDX-License-Identifier: GPL-3.0-or-later
68

79
namespace Art4\JsonApiClient\Exception;
810

9-
class AccessException extends \RuntimeException implements Exception, \Throwable
10-
{
11-
}
11+
class AccessException extends \RuntimeException implements Exception, \Throwable {}

src/Exception/Exception.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
// SPDX-FileCopyrightText: 2015-2023 Artur Weigandt https://wlabs.de/kontakt
46
//
57
// SPDX-License-Identifier: GPL-3.0-or-later
@@ -10,6 +12,4 @@
1012
* @deprecated `\Art4\JsonApiClient\Exception\Exception` will extend `\Throwable` in v2.0. Do the same in your implementation now to avoid errors.
1113
*/
1214
// interface Exception extends \Throwable
13-
interface Exception
14-
{
15-
}
15+
interface Exception {}

src/Exception/FactoryException.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
// SPDX-FileCopyrightText: 2015-2023 Artur Weigandt https://wlabs.de/kontakt
46
//
57
// SPDX-License-Identifier: GPL-3.0-or-later
68

79
namespace Art4\JsonApiClient\Exception;
810

9-
class FactoryException extends \Exception implements Exception, \Throwable
10-
{
11-
}
11+
class FactoryException extends \Exception implements Exception, \Throwable {}

src/Exception/InputException.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
// SPDX-FileCopyrightText: 2015-2023 Artur Weigandt https://wlabs.de/kontakt
46
//
57
// SPDX-License-Identifier: GPL-3.0-or-later
68

79
namespace Art4\JsonApiClient\Exception;
810

9-
class InputException extends \Exception implements Exception, \Throwable
10-
{
11-
}
11+
class InputException extends \Exception implements Exception, \Throwable {}

0 commit comments

Comments
 (0)