Skip to content

Commit 33170e9

Browse files
authored
add CI, reformat a3 code to PSR12 (#117)
1 parent da1f1bc commit 33170e9

Some content is hidden

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

64 files changed

+6085
-5419
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: checks-A3
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
defaults:
10+
run:
11+
working-directory: ./adminator3
12+
13+
permissions:
14+
pull-requests: write
15+
16+
jobs:
17+
basic-checks:
18+
runs-on: ${{ matrix.os }}
19+
strategy:
20+
matrix:
21+
os: [ubuntu-latest]
22+
php-versions: ['8.2']
23+
24+
name: Test on ${{ matrix.os }} with PHP ${{ matrix.php-versions }}
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v2
28+
29+
- name: Setup PHP
30+
uses: shivammathur/setup-php@v2
31+
with:
32+
php-version: ${{ matrix.php-versions }}
33+
coverage: none
34+
35+
- name: Print PHP version
36+
run: php -v
37+
38+
- name: Install dependencies
39+
run: composer install --ignore-platform-reqs
40+
41+
# - name: Run the tests
42+
# run: composer phpunit
43+
44+
- name: PHP CodeSniffer
45+
id: phpcs
46+
continue-on-error: true
47+
run: |
48+
composer \
49+
run \
50+
phpcs \
51+
-- \
52+
--standard=PSR12 \
53+
app \
54+
boostrap \
55+
print \
56+
rss
57+
58+
- uses: mainmatter/continue-on-error-comment@v1
59+
with:
60+
repo-token: ${{ secrets.GITHUB_TOKEN }}
61+
outcome: ${{ steps.phpcs.outcome }}
62+
test-id: Step Php-CS Failed on OS ${{ matrix.os }} and PHP ${{ matrix.php-versions }}
63+
64+
# - name: PHP CodeSniffer Fix
65+
# run: |
66+
# composer \
67+
# run \
68+
# phpcbf \
69+
# -- \
70+
# --standard=PSR12 \
71+
# boostrap \
72+
# config \
73+
# resources \
74+
# templates \
75+
# app
76+
77+
- name: PHP-CS-Fixer
78+
if: always()
79+
run: |
80+
php \
81+
vendor/friendsofphp/php-cs-fixer/php-cs-fixer \
82+
check \
83+
--show-progress=dots \
84+
-v
85+

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,4 @@ extras/documentation
4040
adminator3/.php_cs.cache
4141
a3-logs/
4242
adminator3/export/vlastnici-sro.xls
43+
adminator3/.php-cs-fixer.cache

.vscode/settings.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
{
2-
"php.version": "8.2"
3-
}
2+
"php.version": "8.2",
3+
"editor.insertSpaces": true,
4+
"editor.tabSize": 4,
5+
}

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ sqlcmd query "SELECT Name from sys.databases;"
108108
- https://github.com/open-telemetry/opentelemetry-php-contrib/tree/main/src/Instrumentation/Slim
109109
- https://github.com/open-telemetry/opentelemetry-php-contrib/tree/main/src/Logs/Monolog
110110

111+
### Github Actions
112+
- https://github.com/marketplace/actions/continue-on-error-comment
113+
111114
## Author
112115
Patrik Majer
113116

adminator3/.php-cs-fixer.cache

Lines changed: 0 additions & 1 deletion
This file was deleted.

adminator3/.php-cs-fixer.dist.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
$finder = (new PhpCsFixer\Finder())
4+
->in(__DIR__)
5+
->exclude([
6+
'config',
7+
'database',
8+
'include/font',
9+
'templates_c',
10+
'tests/fixtures',
11+
'plugins'
12+
])
13+
->notPath([
14+
'test.php',
15+
])
16+
;
17+
18+
return (new PhpCsFixer\Config())
19+
->setRules([
20+
'@PSR12' => true,
21+
// '@PhpCsFixer' => true,
22+
'array_indentation' => true,
23+
24+
])
25+
->setFinder($finder)
26+
;

adminator3/app/Auth/Password.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ public function validatePassword()
5050
$validationNew = $this->validator->validate(
5151
array('password' => $this->requestData['password']),
5252
[
53-
'password' => v::noWhitespace()->notEmpty()->length(7, null),
54-
],
53+
'password' => v::noWhitespace()->notEmpty()->length(7, null),
54+
],
5555
" ",
5656
" "
5757
);
@@ -72,9 +72,9 @@ public function changePassword()
7272
{
7373

7474
$this->loggedUserData = array(
75-
"email" => (string) Sentinel::getUser()->email,
76-
"password" => (string) Sentinel::getUser()->password
77-
);
75+
"email" => (string) Sentinel::getUser()->email,
76+
"password" => (string) Sentinel::getUser()->password
77+
);
7878
// $this->logger->debug("passwordHelper\changePassword current data: " . var_export($this->loggedUserData,true));
7979

8080
$valRes = $this->validatePassword();

adminator3/app/Controllers/Auth/AuthController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ public function signin(ServerRequestInterface $request, ResponseInterface $respo
4949
{
5050
if ($request->getMethod() == "POST") {
5151
$data = array(
52-
'email' => $request->getParsedBody()['slimUsername'],
53-
'password' => $request->getParsedBody()['slimPassword'],
52+
'email' => $request->getParsedBody()['slimUsername'],
53+
'password' => $request->getParsedBody()['slimPassword'],
5454
);
5555

5656
try {
@@ -60,7 +60,7 @@ public function signin(ServerRequestInterface $request, ResponseInterface $respo
6060
[
6161
'email',
6262
'password',
63-
]
63+
]
6464
),
6565
isset($data['persist'])
6666
)

adminator3/app/Controllers/othersController.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,14 @@ public function board(ServerRequestInterface $request, ResponseInterface $respon
8383
$this->smarty->assign("mod_hlaska", "->> Staré zprávy");
8484
}
8585

86-
$nastenka->view_number = 10; //zprávy budou zobrazeny po ...
86+
$nastenka->view_number = 10; //zprávy budou zobrazeny po ...
8787

88-
$zpravy = $nastenka->show_messages();
88+
$zpravy = $nastenka->show_messages();
8989

90-
$this->smarty->assign("zpravy", $zpravy);
90+
$this->smarty->assign("zpravy", $zpravy);
9191

92-
$page = $nastenka->show_pages();
93-
$this->smarty->assign("strany", $page);
92+
$page = $nastenka->show_pages();
93+
$this->smarty->assign("strany", $page);
9494

9595
else:
9696

adminator3/app/Core/ArchivZmen.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,9 @@ public function insertItem(int $actionType, array $actionData, int $actionResult
141141

142142
$item = Model::create(
143143
[
144-
'akce' => $actionBody,
145-
'vysledek' => $actionResult,
146-
'provedeno_kym' => $loggedUserEmail
144+
'akce' => $actionBody,
145+
'vysledek' => $actionResult,
146+
'provedeno_kym' => $loggedUserEmail
147147
]
148148
);
149149

@@ -179,9 +179,9 @@ public function insertItemDiff(int $actionType, array $dataOrig, array $dataUpda
179179

180180
$item = Model::create(
181181
[
182-
'akce' => $actionBody,
183-
'vysledek' => $args[0]['actionResult'],
184-
'provedeno_kym' => $args[0]['loggedUserEmail']
182+
'akce' => $actionBody,
183+
'vysledek' => $args[0]['actionResult'],
184+
'provedeno_kym' => $args[0]['loggedUserEmail']
185185
]
186186
);
187187

0 commit comments

Comments
 (0)