Skip to content

Commit 25d4d16

Browse files
committed
modernized
1 parent df60ea2 commit 25d4d16

13 files changed

+430
-188
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ composer.phar
1111
/.phpunit.result.cache
1212
/src/.php-cs-fixer.cache
1313
/.phpunit.cache/
14+
/.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 RealpadTakeout package
7+
*
8+
* https://github.com/Spoje-NET/PHP-Realpad-Takeout
9+
*
10+
* (c) Spoje.Net IT s.r.o. <http://spojenenet.cz/>
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 RealpadTakeout package
22+
23+
https://github.com/Spoje-NET/PHP-Realpad-Takeout
24+
25+
(c) Spoje.Net IT s.r.o. <http://spojenenet.cz/>
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: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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

composer.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,17 @@
2121
"email": "[email protected]"
2222
}
2323
],
24-
"minimum-stability": "dev"
24+
"require-dev": {
25+
"phpunit/phpunit": "*",
26+
"phpstan/phpstan": "*",
27+
"friendsofphp/php-cs-fixer": "^3.61",
28+
"ergebnis/composer-normalize": "^2.43",
29+
"ergebnis/php-cs-fixer-config": "^6.34"
30+
},
31+
"minimum-stability": "dev",
32+
"config": {
33+
"allow-plugins": {
34+
"ergebnis/composer-normalize": true
35+
}
36+
}
2537
}

debian/Jenkinsfile

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!groovy
22

3-
String[] distributions = ['debian:bullseye', 'debian:bookworm', 'ubuntu:focal', 'ubuntu:jammy']
3+
String[] distributions = ['debian:bullseye', 'debian:bookworm', 'debian:trixie', 'ubuntu:focal', 'ubuntu:jammy', 'ubuntu:noble']
44

55
String vendor = 'vitexsoftware'
66
String distribution = ''
@@ -25,16 +25,18 @@ distributions.each {
2525
println "Dist:" + distribution
2626

2727
def dist = distribution.split(':')
28-
// distroFamily = dist[0]
2928
distroCodename = dist[1]
3029

3130
def buildImage = ''
3231

32+
def artifacts = []
33+
3334
node {
3435
ansiColor('xterm') {
3536
stage('Checkout ' + distribution) {
37+
checkout scm
3638
buildImage = docker.image(vendor + '/' + distribution)
37-
sh 'git checkout debian/changelog'
39+
sh 'git checkout debian/changelog'
3840
def version = sh (
3941
script: 'dpkg-parsechangelog --show-field Version',
4042
returnStdout: true
@@ -48,6 +50,10 @@ distributions.each {
4850
sh 'sudo chown jenkins:jenkins ..'
4951
sh 'debuild-pbuilder -i -us -uc -b'
5052
sh 'mkdir -p $WORKSPACE/dist/debian/ ; rm -rf $WORKSPACE/dist/debian/* ; for deb in $(cat debian/files | awk \'{print $1}\'); do mv "../$deb" $WORKSPACE/dist/debian/; done'
53+
artifacts = sh (
54+
script: "cat debian/files | awk '{print \$1}'",
55+
returnStdout: true
56+
).trim().split('\n')
5157
}
5258
}
5359

@@ -58,12 +64,20 @@ distributions.each {
5864
sh 'echo "deb [trusted=yes] file://///$WORKSPACE/dist/debian/ ./" | sudo tee /etc/apt/sources.list.d/local.list'
5965
sh 'sudo apt-get update --allow-releaseinfo-change'
6066
sh 'echo "INSTALATION"'
61-
sh 'IFS="\n\b"; for package in `ls $WORKSPACE/dist/debian/ | grep .deb | awk -F_ \'{print \$1}\'` ; do echo -e "${GREEN} installing ${package} on `lsb_release -sc` ${ENDCOLOR} " ; sudo DEBIAN_FRONTEND=noninteractive DEBCONF_DEBUG=' + debconf_debug + ' apt-get -y install $package ; done;'
62-
stash includes: 'dist/**', name: 'dist-' + distroCodename
67+
artifacts.each { deb_file ->
68+
if (deb_file.endsWith('.deb')) {
69+
sh 'echo -e "${GREEN} installing ' + deb_file + ' on `lsb_release -sc` ${ENDCOLOR} "'
70+
sh 'sudo DEBIAN_FRONTEND=noninteractive DEBCONF_DEBUG=' + debconf_debug + ' apt-get -y install $WORKSPACE/dist/debian/' + deb_file
71+
}
72+
}
6373
}
6474
}
6575
stage('Copy artifacts ' + distribution ) {
6676
buildImage.inside {
77+
artifacts.each { deb_file ->
78+
println "Copying artifact: " + deb_file
79+
archiveArtifacts artifacts: 'dist/debian/' + deb_file
80+
}
6781
sh 'mv $WORKSPACE/dist/debian/*.deb $WORKSPACE'
6882
}
6983
}

debian/changelog

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
php-spojenet-realpad-takeout (0.1.1) UNRELEASED; urgency=low
1+
php-spojenet-realpad-takeout (0.2.0) UNRELEASED; urgency=medium
2+
3+
* Modernized
4+
5+
-- vitex <[email protected]> Sun, 27 Oct 2024 15:56:24 +0100
6+
7+
php-spojenet-realpad-takeout (0.1.1) unstable; urgency=low
28

39
[ Vítězslav Dvořák ]
410
* Initial release. Closes: #nnnn
@@ -7,4 +13,4 @@ php-spojenet-realpad-takeout (0.1.1) UNRELEASED; urgency=low
713
[ vitex ]
814
* final build
915

10-
-- vitex <[email protected]> Thu, 09 Nov 2023 08:39:12 +0100
16+
-- vitex <[email protected]> Sun, 27 Oct 2024 15:56:14 +0100

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)