Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add CI, reformat a3 code to PSR12 #117

Merged
merged 22 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions .github/workflows/checks-adminator3.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: checks-A3

on:
push:
branches:
- master
pull_request:

defaults:
run:
working-directory: ./adminator3

permissions:
pull-requests: write

jobs:
basic-checks:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
php-versions: ['8.2']

name: Test on ${{ matrix.os }} with PHP ${{ matrix.php-versions }}
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
coverage: none

- name: Print PHP version
run: php -v

- name: Install dependencies
run: composer install --ignore-platform-reqs

# - name: Run the tests
# run: composer phpunit

- name: PHP CodeSniffer
id: phpcs
continue-on-error: true
run: |
composer \
run \
phpcs \
-- \
--standard=PSR12 \
app \
boostrap \
print \
rss

- uses: mainmatter/continue-on-error-comment@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
outcome: ${{ steps.phpcs.outcome }}
test-id: Step Php-CS Failed on OS ${{ matrix.os }} and PHP ${{ matrix.php-versions }}

# - name: PHP CodeSniffer Fix
# run: |
# composer \
# run \
# phpcbf \
# -- \
# --standard=PSR12 \
# boostrap \
# config \
# resources \
# templates \
# app

- name: PHP-CS-Fixer
if: always()
run: |
php \
vendor/friendsofphp/php-cs-fixer/php-cs-fixer \
check \
--show-progress=dots \
-v

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ extras/documentation
adminator3/.php_cs.cache
a3-logs/
adminator3/export/vlastnici-sro.xls
adminator3/.php-cs-fixer.cache
6 changes: 4 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{
"php.version": "8.2"
}
"php.version": "8.2",
"editor.insertSpaces": true,
"editor.tabSize": 4,
}
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ sqlcmd query "SELECT Name from sys.databases;"
- https://github.com/open-telemetry/opentelemetry-php-contrib/tree/main/src/Instrumentation/Slim
- https://github.com/open-telemetry/opentelemetry-php-contrib/tree/main/src/Logs/Monolog

### Github Actions
- https://github.com/marketplace/actions/continue-on-error-comment

## Author
Patrik Majer

Expand Down
1 change: 0 additions & 1 deletion adminator3/.php-cs-fixer.cache

This file was deleted.

26 changes: 26 additions & 0 deletions adminator3/.php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

$finder = (new PhpCsFixer\Finder())
->in(__DIR__)
->exclude([
'config',
'database',
'include/font',
'templates_c',
'tests/fixtures',
'plugins'
])
->notPath([
'test.php',
])
;

return (new PhpCsFixer\Config())
->setRules([
'@PSR12' => true,
// '@PhpCsFixer' => true,
'array_indentation' => true,

])
->setFinder($finder)
;
10 changes: 5 additions & 5 deletions adminator3/app/Auth/Password.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public function validatePassword()
$validationNew = $this->validator->validate(
array('password' => $this->requestData['password']),
[
'password' => v::noWhitespace()->notEmpty()->length(7, null),
],
'password' => v::noWhitespace()->notEmpty()->length(7, null),
],
" ",
" "
);
Expand All @@ -72,9 +72,9 @@ public function changePassword()
{

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

$valRes = $this->validatePassword();
Expand Down
6 changes: 3 additions & 3 deletions adminator3/app/Controllers/Auth/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public function signin(ServerRequestInterface $request, ResponseInterface $respo
{
if ($request->getMethod() == "POST") {
$data = array(
'email' => $request->getParsedBody()['slimUsername'],
'password' => $request->getParsedBody()['slimPassword'],
'email' => $request->getParsedBody()['slimUsername'],
'password' => $request->getParsedBody()['slimPassword'],
);

try {
Expand All @@ -60,7 +60,7 @@ public function signin(ServerRequestInterface $request, ResponseInterface $respo
[
'email',
'password',
]
]
),
isset($data['persist'])
)
Expand Down
10 changes: 5 additions & 5 deletions adminator3/app/Controllers/othersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@ public function board(ServerRequestInterface $request, ResponseInterface $respon
$this->smarty->assign("mod_hlaska", "->> Staré zprávy");
}

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

$zpravy = $nastenka->show_messages();
$zpravy = $nastenka->show_messages();

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

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

else:

Expand Down
12 changes: 6 additions & 6 deletions adminator3/app/Core/ArchivZmen.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ public function insertItem(int $actionType, array $actionData, int $actionResult

$item = Model::create(
[
'akce' => $actionBody,
'vysledek' => $actionResult,
'provedeno_kym' => $loggedUserEmail
'akce' => $actionBody,
'vysledek' => $actionResult,
'provedeno_kym' => $loggedUserEmail
]
);

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

$item = Model::create(
[
'akce' => $actionBody,
'vysledek' => $args[0]['actionResult'],
'provedeno_kym' => $args[0]['loggedUserEmail']
'akce' => $actionBody,
'vysledek' => $args[0]['actionResult'],
'provedeno_kym' => $args[0]['loggedUserEmail']
]
);

Expand Down
Loading
Loading