Skip to content

Commit 84b2a60

Browse files
committed
code modernized
1 parent b5f53a4 commit 84b2a60

24 files changed

+507
-359
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,8 @@
1010
/.phpunit.cache/
1111
/nbproject/
1212
/.env
13+
/.build/
14+
/debian/.debhelper/
15+
/debian/php-spojenet-subreg.debhelper.log
16+
/debian/php-spojenet-subreg.substvars
17+
/debian/php-spojenet-subreg/

.php-cs-fixer.dist.php

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* This file is part of the PHPSubreg package
7+
*
8+
* https://github.com/Spoje-NET/php-subreg
9+
*
10+
* (c) Vítězslav Dvořák <http://spojenet.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 PHPSubreg package
22+
23+
https://github.com/Spoje-NET/php-subreg
24+
25+
(c) Vítězslav Dvořák <http://spojenet.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('Examples')
101+
->in('src')
102+
->in('tests');
103+
104+
$config->setCacheFile(__DIR__.'/.build/php-cs-fixer/.php-cs-fixer.cache');
105+
106+
return $config;

Examples/CheckDomain.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,31 @@
11
<?php
2+
3+
declare(strict_types=1);
4+
25
/**
3-
* Subreg - Usage Example
6+
* This file is part of the PHPSubreg package
7+
*
8+
* https://github.com/Spoje-NET/php-subreg
49
*
5-
* @author Vítězslav Dvořák <info@vitexsoftware.cz>
6-
* @copyright (C) 2018 Spoje.Net
10+
* (c) Vítězslav Dvořák <http://spojenet.cz/>
11+
*
12+
* For the full copyright and license information, please view the LICENSE
13+
* file that was distributed with this source code.
714
*/
815

916
namespace Subreg;
1017

1118
require_once '../vendor/autoload.php';
1219

13-
\Ease\Shared::instanced()->loadConfig('../config.json');
14-
15-
$client = new Client(\Ease\Shared::instanced()->configuration);
20+
\Ease\Shared::init(['SUBREG_LOCATION', 'SUBREG_URI', 'SUBREG_LOGIN', 'SUBREG_PASSWORD'], '../.env');
1621

22+
$client = new Client(Client::env2conf(\Ease\Shared::instanced()->configuration));
1723

1824
$unexistentDomain = strtolower(\Ease\Functions::randomString()).'.cz';
1925

2026
$response = $client->checkDomain($unexistentDomain);
2127

22-
$existingDomain = 'spoje.net';
28+
$existingDomain = 'spoje.net';
2329

2430
$response = $client->checkDomain($existingDomain);
2531
var_dump($response);

Examples/DomainList.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* This file is part of the PHPSubreg package
7+
*
8+
* https://github.com/Spoje-NET/php-subreg
9+
*
10+
* (c) Vítězslav Dvořák <http://spojenet.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+
namespace Subreg;
17+
18+
require_once '../vendor/autoload.php';
19+
20+
\Ease\Shared::init(['SUBREG_LOCATION', 'SUBREG_URI', 'SUBREG_LOGIN', 'SUBREG_PASSWORD'], '../.env');
21+
22+
$client = new Client(Client::env2conf(\Ease\Shared::instanced()->configuration));
23+
24+
$response = $client->call('Domains_List');
25+
26+
var_dump($response);

Examples/GetDnsZone.php

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

3+
declare(strict_types=1);
4+
35
/**
4-
* Subreg - Usage Example
6+
* This file is part of the PHPSubreg package
7+
*
8+
* https://github.com/Spoje-NET/php-subreg
9+
*
10+
* (c) Vítězslav Dvořák <http://spojenet.cz/>
511
*
6-
* @author Vítězslav Dvořák <info@vitexsoftware.cz>
7-
* @copyright (C) 2024 Spoje.Net
12+
* For the full copyright and license information, please view the LICENSE
13+
* file that was distributed with this source code.
814
*/
915

1016
namespace Subreg;
@@ -15,8 +21,8 @@
1521
'SUBREG_LOCATION',
1622
'SUBREG_URI',
1723
'SUBREG_LOGIN',
18-
'SUBREG_PASSWORD'
19-
], '../.env');
24+
'SUBREG_PASSWORD',
25+
], '../.env');
2026

2127
$client = new Client(Client::env2conf(\Ease\Shared::instanced()->configuration));
2228
$client->login();

Examples/GetPriceList.php

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
11
<?php
2+
3+
declare(strict_types=1);
4+
25
/**
3-
* Subreg - RegisterDomain Example
6+
* This file is part of the PHPSubreg package
7+
*
8+
* https://github.com/Spoje-NET/php-subreg
49
*
5-
* @author Vítězslav Dvořák <info@vitexsoftware.cz>
6-
* @copyright (C) 2019 Spoje.Net
10+
* (c) Vítězslav Dvořák <http://spojenet.cz/>
11+
*
12+
* For the full copyright and license information, please view the LICENSE
13+
* file that was distributed with this source code.
714
*/
815

916
namespace Subreg;
1017

1118
require_once '../vendor/autoload.php';
1219

13-
\Ease\Shared::instanced()->loadConfig('../config.json');
14-
15-
$client = new Client(\Ease\Shared::instanced()->configuration);
20+
\Ease\Shared::init(['SUBREG_LOCATION', 'SUBREG_URI', 'SUBREG_LOGIN', 'SUBREG_PASSWORD'], '../.env');
1621

22+
$client = new Client(Client::env2conf(\Ease\Shared::instanced()->configuration));
1723

1824
print_r($client->getPricelist('KONCOVA'));
1925

20-
//print_r($client->pricelist());
21-
26+
// print_r($client->pricelist());

Examples/RegisterDomain.php

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,38 @@
11
<?php
2+
3+
declare(strict_types=1);
4+
25
/**
3-
* Subreg - RegisterDomain Example
6+
* This file is part of the PHPSubreg package
7+
*
8+
* https://github.com/Spoje-NET/php-subreg
49
*
5-
* @author Vítězslav Dvořák <info@vitexsoftware.cz>
6-
* @copyright (C) 2018 Spoje.Net
10+
* (c) Vítězslav Dvořák <http://spojenet.cz/>
11+
*
12+
* For the full copyright and license information, please view the LICENSE
13+
* file that was distributed with this source code.
714
*/
815

916
namespace Subreg;
1017

1118
require_once '../vendor/autoload.php';
1219

13-
\Ease\Shared::instanced()->loadConfig('../config.json');
20+
\Ease\Shared::init(['SUBREG_LOCATION', 'SUBREG_URI', 'SUBREG_LOGIN', 'SUBREG_PASSWORD'], '../.env');
1421

15-
$client = new Client(\Ease\Shared::instanced()->configuration);
22+
$client = new Client(Client::env2conf(\Ease\Shared::instanced()->configuration));
1623

1724
$unexistentDomain = strtolower(\Ease\Sand::randomString()).'.cz';
1825

19-
$nsHosts = array("ns.spoje.net", "ns2.spoje.net");
20-
21-
print_r($client->registerDomain($unexistentDomain, 'G-000001', 'G-000001',
22-
'G-000001', 'ukulele', $nsHosts));
26+
$nsHosts = ['ns.spoje.net', 'ns2.spoje.net'];
2327

28+
print_r($client->registerDomain(
29+
$unexistentDomain,
30+
'G-000001',
31+
'G-000001',
32+
'G-000001',
33+
'ukulele',
34+
$nsHosts,
35+
));
2436

2537
$response = $client->checkDomain($unexistentDomain);
2638

Makefile

Lines changed: 19 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,25 @@
1-
repoversion=$(shell LANG=C aptitude show php-subreg | grep Version: | awk '{print $$2}')
2-
nextversion=$(shell echo $(repoversion) | perl -ne 'chomp; print join(".", splice(@{[split/\./,$$_]}, 0, -1), map {++$$_} pop @{[split/\./,$$_]}), "\n";')
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}'
35

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
49

5-
all: build install
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
613

7-
fresh:
8-
git pull
9-
composer install
10-
build:
11-
echo build
12-
13-
14-
clean:
15-
rm -rf debian/php-subreg
16-
rm -rf debian/subreg .phpunit.result.cache debian/subreg.debhelper.log
17-
rm -rf debian/subreg-doc
18-
rm -rf debian/*.log
19-
rm -rf debian/*.substvars
20-
rm -rf docs/*
21-
rm -f debianTest/composer.lock
22-
rm -rf vendor/* composer.lock
23-
24-
apigen:
25-
VERSION=`cat debian/composer.json | grep version | awk -F'"' '{print $4}'`; \
26-
apigen generate --source src --destination docs --title "subreg ${VERSION}" --charset UTF-8 --access-levels public --access-levels protected --php --tree
27-
28-
test: pretest phpunit
29-
30-
pretest:
31-
composer --ansi --no-interaction update
14+
.PHONY: tests
15+
tests: vendor
16+
vendor/bin/phpunit tests
3217

33-
phpunit: pretest
34-
vendor/bin/phpunit --bootstrap tests/bootstrap.php
35-
36-
deb:
37-
dpkg-buildpackage -A -us -uc
38-
39-
rpm:
40-
rpmdev-bumpspec --comment="Build" --userstring="Vítězslav Dvořák <info@vitexsoftware.cz>" subreg.spec
41-
rpmbuild -ba subreg.spec
42-
43-
verup:
44-
git commit debian/composer.json debian/version debian/revision -m "`cat debian/version`-`cat debian/revision`"
45-
git push origin master
46-
47-
dimage:
48-
docker build -t vitexsoftware/subreg .
49-
50-
release:
51-
echo Release v$(nextversion)
52-
dch -v $(nextversion) `git log -1 --pretty=%B | head -n 1`
53-
debuild -i -us -uc -b
54-
git commit -a -m "Release v$(nextversion)"
55-
git tag -a $(nextversion) -m "version $(nextversion)"
18+
.PHONY: vendor
19+
vendor: composer.json composer.lock ## Installs composer dependencies
20+
composer install
5621

22+
.PHONY: cs
23+
cs: ## Update Coding Standards
24+
vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php --diff --verbose
5725

58-
.PHONY : install
59-

0 commit comments

Comments
 (0)