Skip to content

Commit 801bd42

Browse files
authored
workflow und phpstan level 5 CS (#465)
* workflow und phpstan level 5 CS
1 parent 6173fa9 commit 801bd42

File tree

322 files changed

+4829
-52532
lines changed

Some content is hidden

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

322 files changed

+4829
-52532
lines changed

.github/workflows/code-style.yml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: PHP-CS-Fixer
2+
3+
on:
4+
push:
5+
branches: [ master, main ]
6+
pull_request:
7+
branches: [ master, main ]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
code-style:
14+
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: write # for Git to git apply
18+
19+
steps:
20+
- uses: actions/checkout@v3
21+
22+
- name: Setup PHP
23+
uses: shivammathur/setup-php@v2
24+
with:
25+
php-version: '8.1'
26+
extensions: gd, intl, pdo_mysql
27+
coverage: none # disable xdebug, pcov
28+
29+
# install dependencies from composer.json
30+
- name: Install test dependencies
31+
env:
32+
COMPOSER: composer.json
33+
run: composer install --prefer-dist --no-progress
34+
35+
# run php-cs-fixer
36+
- name: Run PHP CS Fixer
37+
run: composer cs-dry
38+
39+
# commit and push fixed files
40+
# - uses: stefanzweifel/git-auto-commit-action@v4
41+
# with:
42+
# commit_message: Apply php-cs-fixer changes

.github/workflows/phpstan.yml

-27
This file was deleted.

.github/workflows/phpunit.yml

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: PHPUnit
2+
3+
on:
4+
push:
5+
branches: [ master, main ]
6+
pull_request:
7+
branches: [ master, main ]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
phpunit:
14+
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: write # for Git to git apply
18+
19+
steps:
20+
- uses: actions/checkout@v3
21+
22+
# setup PHP v8, install some extensions
23+
- name: Setup PHP
24+
uses: shivammathur/setup-php@v2
25+
with:
26+
php-version: '8.2'
27+
extensions: gd, intl, pdo_mysql
28+
coverage: none # disable xdebug, pcov
29+
30+
# download the latest REDAXO release and unzip it
31+
# credits https://blog.markvincze.com/download-artifacts-from-a-latest-github-release-in-sh-and-powershell/
32+
- name: Download latest REDAXO release
33+
run: |
34+
LATEST_RELEASE=$(curl -L -s -H 'Accept: application/json' https://github.com/redaxo/redaxo/releases/latest)
35+
REDAXO_VERSION=$(echo $LATEST_RELEASE | sed -e 's/.*"tag_name":"\([^"]*\)".*/\1/')
36+
echo "Downloaded REDAXO $REDAXO_VERSION"
37+
curl -Ls -o redaxo.zip https://github.com/redaxo/redaxo/releases/download/$REDAXO_VERSION/redaxo_$REDAXO_VERSION.zip
38+
unzip -oq redaxo.zip -d redaxo_cms
39+
rm redaxo.zip
40+
41+
# start mysql service, create a database called redaxo5, apply config patch
42+
- name: Init database
43+
run: |
44+
sudo /etc/init.d/mysql start
45+
mysql -uroot -h127.0.0.1 -proot -e 'create database redaxo5;'
46+
47+
# run REDAXO setup with the following parameters
48+
# Language: de
49+
# DB password: root
50+
# Create DB: no
51+
# Admin username: admin
52+
# Admin password: adminpassword
53+
# Error E-mail: [email protected]
54+
- name: Setup REDAXO
55+
run: |
56+
php redaxo_cms/redaxo/bin/console setup:run -n --lang=de_de --agree-license --db-host=127.0.0.1 --db-name=redaxo5 --db-password=root --db-createdb=no --db-setup=normal --admin-username=admin --admin-password=adminpassword [email protected] --ansi
57+
php redaxo_cms/redaxo/bin/console config:set --type boolean debug.enabled true
58+
php redaxo_cms/redaxo/bin/console config:set --type boolean debug.throw_always_exception true
59+
60+
# copy Addon files, ignore some directories...
61+
# install the addon
62+
# if the addon name does not match the repository name, ${{ github.event.repository.name }} must be replaced with the addon name
63+
# if additional addons are needed, they can be installed via the console commands
64+
# see: https://www.redaxo.org/doku/main/basis-addons#console
65+
- name: Copy and install Addons
66+
run: |
67+
rsync -av --exclude='./vendor' --exclude='.github' --exclude='.git' --exclude='redaxo_cms' './' 'redaxo_cms/redaxo/src/addons/${{ github.event.repository.name }}'
68+
redaxo_cms/redaxo/bin/console package:install 'cronjob'
69+
redaxo_cms/redaxo/bin/console package:install 'phpmailer'
70+
redaxo_cms/redaxo/bin/console install:download 'yform' '4.*'
71+
redaxo_cms/redaxo/bin/console package:install 'yform'
72+
redaxo_cms/redaxo/bin/console install:download 'yrewrite' '2.*'
73+
redaxo_cms/redaxo/bin/console package:install 'yrewrite'
74+
redaxo_cms/redaxo/bin/console package:install '${{ github.event.repository.name }}'
75+
76+
# install dependencies from composer.json
77+
- name: Install test dependencies
78+
working-directory: redaxo_cms/redaxo/src/addons/${{ github.event.repository.name }}
79+
env:
80+
COMPOSER: composer.json
81+
run: composer install --prefer-dist --no-progress
82+
83+
- name: Setup Problem Matchers for PHPUnit
84+
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
85+
86+
# run unit tests, see composer.json
87+
- name: Run phpunit
88+
working-directory: redaxo_cms/redaxo/src/addons/${{ github.event.repository.name }}
89+
run: composer test
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Publish release
2+
3+
on:
4+
release:
5+
types:
6+
- published
7+
8+
jobs:
9+
redaxo_publish:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
- uses: shivammathur/setup-php@v2
14+
with:
15+
php-version: "8.2"
16+
- uses: ramsey/composer-install@v2
17+
with:
18+
composer-options: "--no-dev"
19+
- uses: FriendsOfREDAXO/installer-action@v1
20+
with:
21+
myredaxo-username: ${{ secrets.MYREDAXO_USERNAME }}
22+
myredaxo-api-key: ${{ secrets.MYREDAXO_API_KEY }}
23+
description: ${{ github.event.release.body }}
24+

.github/workflows/rexlint.yml

-20
This file was deleted.

.github/workflows/rexstan.yml

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: rexstan
2+
3+
on:
4+
push:
5+
branches: [ master, main ]
6+
pull_request:
7+
branches: [ master, main ]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
rexstan:
14+
env:
15+
ADDON_KEY: ${{ github.event.repository.name }}
16+
17+
runs-on: ubuntu-latest
18+
permissions:
19+
contents: write # for Git to git apply
20+
21+
steps:
22+
- uses: actions/checkout@v3
23+
24+
# setup PHP v8, install some extensions
25+
- name: Setup PHP
26+
uses: shivammathur/setup-php@v2
27+
with:
28+
php-version: '8.2'
29+
extensions: gd, intl, pdo_mysql
30+
coverage: none # disable xdebug, pcov
31+
32+
# download the latest REDAXO release and unzip it
33+
# credits https://blog.markvincze.com/download-artifacts-from-a-latest-github-release-in-sh-and-powershell/
34+
- name: Download latest REDAXO release
35+
run: |
36+
LATEST_RELEASE=$(curl -L -s -H 'Accept: application/json' https://github.com/redaxo/redaxo/releases/latest)
37+
REDAXO_VERSION=$(echo $LATEST_RELEASE | sed -e 's/.*"tag_name":"\([^"]*\)".*/\1/')
38+
echo "Downloaded REDAXO $REDAXO_VERSION"
39+
curl -Ls -o redaxo.zip https://github.com/redaxo/redaxo/releases/download/$REDAXO_VERSION/redaxo_$REDAXO_VERSION.zip
40+
unzip -oq redaxo.zip -d redaxo_cms
41+
rm redaxo.zip
42+
43+
# start mysql service, create a database called redaxo5, apply config patch
44+
- name: Init database
45+
run: |
46+
sudo /etc/init.d/mysql start
47+
mysql -uroot -h127.0.0.1 -proot -e 'create database redaxo5;'
48+
49+
# run REDAXO setup with the following parameters
50+
# Language: de
51+
# DB password: root
52+
# Create DB: no
53+
# Admin username: admin
54+
# Admin password: adminpassword
55+
# Error E-mail: [email protected]
56+
- name: Setup REDAXO
57+
run: |
58+
php redaxo_cms/redaxo/bin/console setup:run -n --lang=de_de --agree-license --db-host=127.0.0.1 --db-name=redaxo5 --db-password=root --db-createdb=no --db-setup=normal --admin-username=admin --admin-password=adminpassword [email protected] --ansi
59+
php redaxo_cms/redaxo/bin/console config:set --type boolean debug.enabled true
60+
php redaxo_cms/redaxo/bin/console config:set --type boolean debug.throw_always_exception true
61+
62+
# copy Addon files, ignore some directories...
63+
# install the addon
64+
# if the addon name does not match the repository name, ${{ github.event.repository.name }} must be replaced with the addon name
65+
# install latest rexstan
66+
# if additional addons are needed, they can be installed via the console commands
67+
# see: https://www.redaxo.org/doku/main/basis-addons#console
68+
- name: Copy and install Addons
69+
run: |
70+
rsync -av --exclude='./vendor' --exclude='.github' --exclude='.git' --exclude='redaxo_cms' './' 'redaxo_cms/redaxo/src/addons/${{ github.event.repository.name }}'
71+
redaxo_cms/redaxo/bin/console install:download 'rexstan' '1.*'
72+
redaxo_cms/redaxo/bin/console package:install 'rexstan'
73+
redaxo_cms/redaxo/bin/console package:install 'cronjob'
74+
redaxo_cms/redaxo/bin/console package:install 'phpmailer'
75+
redaxo_cms/redaxo/bin/console install:download 'yform' '4.*'
76+
redaxo_cms/redaxo/bin/console package:install 'yform'
77+
redaxo_cms/redaxo/bin/console install:download 'yrewrite' '2.*'
78+
redaxo_cms/redaxo/bin/console package:install 'yrewrite'
79+
redaxo_cms/redaxo/bin/console package:install '${{ github.event.repository.name }}'
80+
81+
# install dependencies from composer.json
82+
- name: Install test dependencies
83+
working-directory: redaxo_cms/redaxo/src/addons/${{ github.event.repository.name }}
84+
env:
85+
COMPOSER: composer.json
86+
run: composer install --prefer-dist --no-progress
87+
88+
# execute rexstan.php to create the needed user-config.neon
89+
- name: Execute .tools/rexstan.php
90+
run: php -f redaxo/src/addons/${{ github.event.repository.name }}/.tools/rexstan.php
91+
working-directory: redaxo_cms
92+
93+
# run rexstan
94+
- id: rexstan
95+
name: Run rexstan
96+
run: redaxo_cms/redaxo/bin/console rexstan:analyze

.gitignore

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
2-
vendor/
1+
vendor/
2+
.phpunit.result.cache
3+
.php-cs-fixer.cache

.php-cs-fixer.dist.php

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
$finder = (new PhpCsFixer\Finder())
6+
->in(__DIR__)
7+
;
8+
9+
return (new Redaxo\PhpCsFixerConfig\Config())
10+
->setFinder($finder)
11+
;

.tools/bootstrap.php

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
unset($REX);
4+
$REX['REDAXO'] = true;
5+
$REX['HTDOCS_PATH'] = '../../../../';
6+
$REX['BACKEND_FOLDER'] = 'redaxo';
7+
$REX['LOAD_PAGE'] = false;
8+
9+
require __DIR__.'../../../../core/boot.php';
10+
require __DIR__.'../../../../core/packages.php';
11+
12+
// use original error handlers of the tools
13+
rex_error_handler::unregister();

.tools/rexstan.php

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
/**
3+
* boot redaxo and load packages
4+
* necessary to use \rexstan\RexStanUserConfig::save()
5+
*/
6+
unset($REX);
7+
$REX['REDAXO'] = true;
8+
$REX['HTDOCS_PATH'] = './';
9+
$REX['BACKEND_FOLDER'] = 'redaxo';
10+
$REX['LOAD_PAGE'] = false;
11+
12+
require './redaxo/src/core/boot.php';
13+
require './redaxo/src/core/packages.php';
14+
15+
/**
16+
* rexstan config
17+
*/
18+
$extensions = [
19+
// '../../../../redaxo/src/addons/rexstan/config/rex-superglobals.neon',
20+
// '../../../../redaxo/src/addons/rexstan/vendor/phpstan/phpstan/conf/bleedingEdge.neon',
21+
// '../../../../redaxo/src/addons/rexstan/vendor/phpstan/phpstan-strict-rules/rules.neon',
22+
'../../../../redaxo/src/addons/rexstan/vendor/phpstan/phpstan-deprecation-rules/rules.neon',
23+
'../../../../redaxo/src/addons/rexstan/config/phpstan-phpunit.neon',
24+
// '../../../../redaxo/src/addons/rexstan/config/phpstan-dba.neon',
25+
// '../../../../redaxo/src/addons/rexstan/config/cognitive-complexity.neon',
26+
// '../../../../redaxo/src/addons/rexstan/config/code-complexity.neon',
27+
// '../../../../redaxo/src/addons/rexstan/config/dead-code.neon'
28+
];
29+
30+
// get addon key from environment variable
31+
$addon = ['../../../../redaxo/src/addons/' . getenv('ADDON_KEY') . '/'];
32+
33+
/**
34+
* save config
35+
* @param int $level the level to use
36+
* @param array $addon the addon to use
37+
* @param array $extensions the extensions to use
38+
* @param int $phpVersion the php version to use
39+
*/
40+
\rexstan\RexStanUserConfig::save(5, $addon, $extensions, 80203);

boot.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
* @psalm-scope-this rex_addon
66
*/
77

8+
// include __DIR__.'/vendor/guzzlehttp/promises/src/functions_include.php';
9+
// include __DIR__.'/vendor/guzzlehttp/guzzle/src/functions_include.php';
10+
//
11+
812
if (rex::isBackend()) {
913
rex_extension::register('PACKAGES_INCLUDED', static function ($params) {
1014
$plugin = rex_plugin::get('yform', 'manager');
@@ -25,8 +29,8 @@
2529
});
2630
}
2731

28-
rex_ycom::addTable(rex::getTablePrefix().'ycom_user');
29-
rex_yform_manager_dataset::setModelClass(rex::getTablePrefix().'ycom_user', rex_ycom_user::class);
32+
rex_ycom::addTable(rex::getTablePrefix() . 'ycom_user');
33+
rex_yform_manager_dataset::setModelClass(rex::getTablePrefix() . 'ycom_user', rex_ycom_user::class);
3034

3135
if (rex::isBackend() && ('index.php?page=content/edit' == rex_url::currentBackendPage() || 'mediapool' == rex_be_controller::getCurrentPagePart(1))) {
3236
rex_view::addJsFile($this->getAssetsUrl('ycom_backend.js'));

0 commit comments

Comments
 (0)