Skip to content

Commit 51b74c8

Browse files
author
Vítězslav Dvořák
committed
coding standarts update
1 parent a5bb909 commit 51b74c8

17 files changed

Lines changed: 886 additions & 1073 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/composer.lock
22
/vendor/
33
/nbproject/private/
4+
/.build/

.php-cs-fixer.dist.php

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* This file is part of the PohodaSQL package
7+
*
8+
* https://github.com/Spoje-NET/PohodaSQL
9+
*
10+
* (c) Spoje.Net <https://spoje.net>
11+
*
12+
* For the full copyright and license information, please view the LICENSE
13+
* file that was distributed with this source code.
14+
*/
15+
16+
use Ergebnis\PhpCsFixer\Config\Factory;
17+
use Ergebnis\PhpCsFixer\Config\Rules;
18+
use Ergebnis\PhpCsFixer\Config\RuleSet\Php74;
19+
20+
$header = <<<'HEADER'
21+
This file is part of the PohodaSQL package
22+
23+
https://github.com/Spoje-NET/PohodaSQL
24+
25+
(c) Spoje.Net <https://spoje.net>
26+
27+
For the full copyright and license information, please view the LICENSE
28+
file that was distributed with this source code.
29+
HEADER;
30+
31+
$ruleSet = Php74::create()->withHeader($header)->withRules(Rules::fromArray([
32+
'blank_line_before_statement' => [
33+
'statements' => [
34+
'break',
35+
'continue',
36+
'declare',
37+
'default',
38+
'do',
39+
'exit',
40+
'for',
41+
'foreach',
42+
'goto',
43+
'if',
44+
'include',
45+
'include_once',
46+
'require',
47+
'require_once',
48+
'return',
49+
'switch',
50+
'throw',
51+
'try',
52+
'while',
53+
],
54+
],
55+
'concat_space' => [
56+
'spacing' => 'none',
57+
],
58+
'date_time_immutable' => false,
59+
'error_suppression' => false,
60+
'final_class' => false,
61+
'mb_str_functions' => false,
62+
'native_function_invocation' => [
63+
'exclude' => [
64+
'sprintf',
65+
],
66+
'include' => [
67+
'@compiler_optimized',
68+
],
69+
'scope' => 'all',
70+
'strict' => false,
71+
],
72+
'php_unit_internal_class' => false,
73+
'php_unit_test_annotation' => [
74+
'style' => 'prefix',
75+
],
76+
'php_unit_test_class_requires_covers' => false,
77+
'return_to_yield_from' => false,
78+
'phpdoc_array_type' => false,
79+
'phpdoc_list_type' => false,
80+
'attribute_empty_parentheses' => false,
81+
'final_public_method_for_abstract_class' => false,
82+
'class_attributes_separation' => [
83+
'elements' => [
84+
'const' => 'only_if_meta',
85+
'property' => 'only_if_meta',
86+
'trait_import' => 'none',
87+
'case' => 'none',
88+
],
89+
],
90+
'yoda_style' => false,
91+
'php_unit_test_case_static_method_calls' => false,
92+
]));
93+
94+
$config = Factory::fromRuleSet($ruleSet);
95+
96+
$config->getFinder()
97+
->append([
98+
__DIR__.'/.php-cs-fixer.dist.php',
99+
])
100+
->in('src')
101+
->in('tests');
102+
103+
$config->setCacheFile(__DIR__.'/.build/php-cs-fixer/.php-cs-fixer.cache');
104+
105+
return $config;

Makefile

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# vim: set tabstop=8 softtabstop=8 noexpandtab:
2+
.PHONY: help
3+
help: ## Displays this list of targets with descriptions
4+
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}'
5+
6+
.PHONY: static-code-analysis
7+
static-code-analysis: vendor ## Runs a static code analysis with phpstan/phpstan
8+
vendor/bin/phpstan analyse --configuration=phpstan-default.neon.dist --memory-limit=-1
9+
10+
.PHONY: static-code-analysis-baseline
11+
static-code-analysis-baseline: check-symfony vendor ## Generates a baseline for static code analysis with phpstan/phpstan
12+
vendor/bin/phpstan analyze --configuration=phpstan-default.neon.dist --generate-baseline=phpstan-default-baseline.neon --memory-limit=-1
13+
14+
.PHONY: tests
15+
tests: vendor
16+
vendor/bin/phpunit tests
17+
18+
.PHONY: vendor
19+
vendor: composer.json composer.lock ## Installs composer dependencies
20+
composer install
21+
22+
.PHONY: cs
23+
cs: ## Update Coding Standards
24+
vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php --diff --verbose
25+
26+
phar:
27+
phar-composer build .
28+
29+
buildimage:
30+
docker build -f Containerfile -t spojenet/fiobank-statement-downloader:latest .
31+
32+
buildx:
33+
docker buildx build -f Containerfile . --push --platform linux/arm/v7,linux/arm64/v8,linux/amd64 --tag spojenet/fiobank-statement-downloader:latest
34+
35+
drun:
36+
docker run --env-file .env spojenet/fiobank-statement-downloader:latest

composer.json

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
"require": {
1313
"vitexsoftware/ease-fluentpdo": "dev-main"
1414
},
15-
"require-dev": {
16-
"phpunit/phpunit": "^9.5"
17-
},
1815
"autoload": {
1916
"psr-4": {
2017
"SpojeNet\\PohodaSQL\\": "src/SpojeNet/PohodaSQL/"
@@ -24,5 +21,17 @@
2421
"psr-4": {
2522
"Test\\SpojeNet\\PohodaSQL\\": "tests/src/SpojeNet/PohodaSQL/"
2623
}
24+
},
25+
"require-dev": {
26+
"phpunit/phpunit": "*",
27+
"phpstan/phpstan": "*",
28+
"friendsofphp/php-cs-fixer": "^3.61",
29+
"ergebnis/composer-normalize": "^2.43",
30+
"ergebnis/php-cs-fixer-config": "^6.34"
31+
},
32+
"config": {
33+
"allow-plugins": {
34+
"ergebnis/composer-normalize": true
35+
}
2736
}
2837
}

phpstan-default-baseline.neon

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
parameters:
2+
ignoreErrors:

phpstan-default.neon.dist

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
includes:
2+
- phpstan-default-baseline.neon
3+
4+
parameters:
5+
inferPrivatePropertyTypeFromConstructor: true
6+
level: 6
7+
paths:
8+
- src
9+
- tests

0 commit comments

Comments
 (0)