Skip to content

Commit 7141c0d

Browse files
committed
Adds PHP-CS-Fixer config and updates dependencies
Introduces a PHP-CS-Fixer configuration file to enforce coding standards across the project. Updates composer.json to include new development dependencies, improves stability, and adjusts version constraints for required libraries. Adds Makefile targets for code analysis, testing, and standards enforcement. Enhances .gitignore to exclude build artifacts.
1 parent 870be32 commit 7141c0d

15 files changed

+4832
-917
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ composer.phar
1717
/debian/sms-input.debhelper.log
1818
/debian/multiflexi-sms-input.debhelper.log
1919
/debian/tmp/
20+
/.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 SmsInput package
7+
*
8+
* https://github.com/Spoje-NET/Sms-Input
9+
*
10+
* (c) SpojeNetIT s.r.o. <http://spojenet.it/>
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\Php81;
19+
20+
$header = <<<'HEADER'
21+
This file is part of the SmsInput package
22+
23+
https://github.com/Spoje-NET/Sms-Input
24+
25+
(c) SpojeNetIT s.r.o. <http://spojenet.it/>
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 = Php81::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: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,28 @@
1-
none:
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+
226

327
buildimage:
428
docker build -f Containerfile -t vitexsoftware/sms-input:latest .

composer.json

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@
44
"type": "project",
55
"require": {
66
"hsp-dev/huawei-api": "dev-main",
7-
"vitexsoftware/ease-core": "dev-main"
7+
"vitexsoftware/ease-core": "^1.48"
88
},
99
"require-dev": {
10-
"phpstan/phpstan": "2.0.x-dev",
11-
"phpunit/phpunit": "11.0.x-dev"
10+
"phpunit/phpunit": "*",
11+
"phpstan/phpstan": "*",
12+
"friendsofphp/php-cs-fixer": "^3.75",
13+
"ergebnis/composer-normalize": "^2.47",
14+
"ergebnis/php-cs-fixer-config": "^6.46",
15+
"phpstan/phpstan-phpunit": "2.0.x-dev"
1216
},
1317
"license": "MIT",
1418
"autoload": {
@@ -27,6 +31,11 @@
2731
"type": "vcs",
2832
"url": "https://github.com/Spoje-NET/php-hspdev-huaweiapi.git"
2933
}
30-
],
31-
"minimum-stability": "dev"
34+
],
35+
"minimum-stability": "dev",
36+
"config": {
37+
"allow-plugins": {
38+
"ergebnis/composer-normalize": true
39+
}
40+
}
3241
}

0 commit comments

Comments
 (0)