From 4e7eafc8151639a54cf81d9fce4dc5de1108da0c Mon Sep 17 00:00:00 2001 From: Alexander Walther Date: Thu, 5 Sep 2024 21:47:36 +0200 Subject: [PATCH 1/2] add code-style workflow --- .github/workflows/code-style.yml | 42 ++++++++++++++++++++++++++++++++ .gitignore | 4 +++ .php-cs-fixer.dist.php | 11 +++++++++ composer.json | 14 +++++++++++ 4 files changed, 71 insertions(+) create mode 100644 .github/workflows/code-style.yml create mode 100644 .php-cs-fixer.dist.php create mode 100644 composer.json diff --git a/.github/workflows/code-style.yml b/.github/workflows/code-style.yml new file mode 100644 index 0000000..9e8dd7c --- /dev/null +++ b/.github/workflows/code-style.yml @@ -0,0 +1,42 @@ +name: PHP-CS-Fixer + +on: + push: + branches: [ master, main ] + pull_request: + branches: [ master, main ] + +permissions: + contents: read + +jobs: + code-style: + + runs-on: ubuntu-latest + permissions: + contents: write # for Git to git apply + + steps: + - uses: actions/checkout@v3 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.3' + extensions: gd, intl, pdo_mysql + coverage: none # disable xdebug, pcov + + # install dependencies from composer.json + - name: Install test dependencies + env: + COMPOSER: composer.json + run: composer install --prefer-dist --no-progress + + # run php-cs-fixer, fix code styles + - name: Run PHP CS Fixer + run: composer cs-fix + + # commit and push fixed files + - uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: Apply php-cs-fixer changes diff --git a/.gitignore b/.gitignore index ea75c5d..72c620d 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,7 @@ fragments/.DS_Store /playwright-report/ /playwright/.cache/ /screens/ +/.idea +/composer.lock +/.php-cs-fixer.cache +/vendor diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php new file mode 100644 index 0000000..72be593 --- /dev/null +++ b/.php-cs-fixer.dist.php @@ -0,0 +1,11 @@ +in(__DIR__) +; + +return (new Redaxo\PhpCsFixerConfig\Config()) + ->setFinder($finder) + ; diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..e8dda5e --- /dev/null +++ b/composer.json @@ -0,0 +1,14 @@ +{ + "require-dev": { + "redaxo/php-cs-fixer-config": "^2.0", + "friendsofphp/php-cs-fixer": "^3.14" + }, + "replace": { + "psr/log": "*", + "psr/container": "*" + }, + "scripts": { + "cs-dry": "php-cs-fixer fix -v --ansi --dry-run --config=.php-cs-fixer.dist.php", + "cs-fix": "php-cs-fixer fix -v --ansi --config=.php-cs-fixer.dist.php" + } +} From cc6a4075e1c853f0602f11795444e2a3dac99164 Mon Sep 17 00:00:00 2001 From: alxndr-w Date: Thu, 5 Sep 2024 19:48:04 +0000 Subject: [PATCH 2/2] Apply php-cs-fixer changes --- boot.php | 17 +++--- fragments/maintenance/announcement.php | 4 +- fragments/maintenance/login.php | 4 +- fragments/maintenance/reload.php | 2 +- install.php | 8 +-- lib/Maintenance.php | 74 +++++++++++++------------- lib/command/maintenance_off.php | 1 + lib/command/maintenance_on.php | 1 + pages/backend.php | 2 - pages/frontend.php | 22 ++++---- pages/index.php | 2 +- uninstall.php | 4 +- update.php | 9 ++-- 13 files changed, 74 insertions(+), 76 deletions(-) diff --git a/boot.php b/boot.php index 4c325b3..677bdeb 100644 --- a/boot.php +++ b/boot.php @@ -1,5 +1,7 @@ getConfig('block_frontend'))) { - - \FriendsOfREDAXO\Maintenance\Maintenance::checkFrontend(); + if (rex::isFrontend() && (bool) $addon->getConfig('block_frontend')) { + Maintenance::checkFrontend(); } - if (rex::isBackend() && boolval($addon->getConfig('block_backend'))) { - \FriendsOfREDAXO\Maintenance\Maintenance::checkBackend(); + if (rex::isBackend() && (bool) $addon->getConfig('block_backend')) { + Maintenance::checkBackend(); } if (rex::isBackend()) { - \FriendsOfREDAXO\Maintenance\Maintenance::setIndicators(); + Maintenance::setIndicators(); rex_view::addJsFile($addon->getAssetsUrl('dist/bootstrap-tokenfield.js')); rex_view::addJsFile($addon->getAssetsUrl('dist/init_bootstrap-tokenfield.js')); rex_view::addCssFile($addon->getAssetsUrl('dist/css/bootstrap-tokenfield.css')); @@ -35,7 +36,7 @@ if ('maintenance/frontend' === rex_be_controller::getCurrentPage()) { rex_extension::register('OUTPUT_FILTER', static function (rex_extension_point $ep) { $suchmuster = 'class="###maintenance-settings-editor###"'; - $ersetzen = strval(rex_config::get('maintenance', 'editor')); // @phpstan-ignore-line + $ersetzen = (string) rex_config::get('maintenance', 'editor'); // @phpstan-ignore-line $ep->setSubject(str_replace($suchmuster, $ersetzen, $ep->getSubject())); // @phpstan-ignore-line }); } diff --git a/fragments/maintenance/announcement.php b/fragments/maintenance/announcement.php index 54009ce..5901468 100644 --- a/fragments/maintenance/announcement.php +++ b/fragments/maintenance/announcement.php @@ -4,10 +4,10 @@ $end_date = rex_config::get('maintenance', 'announcement_end_date'); $current_date = date('Y-m-d\TH:i:s'); -if ($announcement !== '' && $start_date <= $current_date && $end_date >= $current_date) { +if ('' !== $announcement && $start_date <= $current_date && $end_date >= $current_date) { ?>
- +
diff --git a/fragments/maintenance/login.php b/fragments/maintenance/login.php index bc0a3d1..91b651a 100644 --- a/fragments/maintenance/login.php +++ b/fragments/maintenance/login.php @@ -1,7 +1,7 @@ +if ('password' === rex_config::get('maintenance', 'authentification_mode', '')) { ?>