Skip to content

Commit df56b37

Browse files
committed
add ci pipeline, run rector
1 parent b96a5b9 commit df56b37

14 files changed

Lines changed: 345 additions & 8 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Context**
11+
Contao version:
12+
Bundle version:
13+
PHP version:
14+
15+
**Description**
16+
<!-- Please describe the issue and provide reproduction steps (in a clean contao installation). If you report an error, please provide the full error message (ideally a screenshot of the error page in dev mode) -->

.github/workflows/ci.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: CI
2+
on: [ push ]
3+
4+
jobs:
5+
phpstan:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- name: Setup PHP
9+
uses: shivammathur/setup-php@v2
10+
with:
11+
php-version: 8.1
12+
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
16+
- name: Install the dependencies
17+
uses: ramsey/composer-install@v3
18+
with:
19+
composer-options: "--no-plugins"
20+
21+
- name: PHPStan
22+
run: vendor/bin/phpstan analyse -c phpstan.neon
23+
24+
rector:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: Setup PHP
28+
uses: shivammathur/setup-php@v2
29+
with:
30+
php-version: 8.1
31+
32+
- name: Checkout
33+
uses: actions/checkout@v4
34+
35+
- name: Install the dependencies
36+
uses: ramsey/composer-install@v3
37+
with:
38+
composer-options: "--no-plugins"
39+
40+
- name: Rector
41+
run: vendor/bin/rector --dry-run --no-progress-bar
42+
43+
ecs:
44+
name: ECS
45+
runs-on: ubuntu-latest
46+
steps:
47+
- name: Setup PHP
48+
uses: shivammathur/setup-php@v2
49+
with:
50+
php-version: 8.1
51+
extensions: dom, fileinfo, filter, gd, hash, intl, json, mbstring, mysqli, pcre, pdo_mysql, zlib
52+
coverage: none
53+
54+
- name: Checkout
55+
uses: actions/checkout@v4
56+
with:
57+
show-progress: false
58+
59+
- name: Install the dependencies
60+
uses: ramsey/composer-install@v3
61+
with:
62+
composer-options: "--no-plugins"
63+
64+
- name: Run ECS
65+
run: vendor/bin/ecs check --no-progress-bar

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
.idea
1+
.idea
2+
composer.lock
3+
vendor

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
## [0.1.0] - 2024-09-03
6+
Initial release

LICENSE.md

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
GNU Lesser General Public License
2+
=================================
3+
4+
_Version 3, 29 June 2007_
5+
_Copyright © 2007 Free Software Foundation, Inc. &lt;<http://fsf.org/>&gt;_
6+
7+
Everyone is permitted to copy and distribute verbatim copies
8+
of this license document, but changing it is not allowed.
9+
10+
11+
This version of the GNU Lesser General Public License incorporates
12+
the terms and conditions of version 3 of the GNU General Public
13+
License, supplemented by the additional permissions listed below.
14+
15+
### 0. Additional Definitions
16+
17+
As used herein, “this License” refers to version 3 of the GNU Lesser
18+
General Public License, and the “GNU GPL” refers to version 3 of the GNU
19+
General Public License.
20+
21+
“The Library” refers to a covered work governed by this License,
22+
other than an Application or a Combined Work as defined below.
23+
24+
An “Application” is any work that makes use of an interface provided
25+
by the Library, but which is not otherwise based on the Library.
26+
Defining a subclass of a class defined by the Library is deemed a mode
27+
of using an interface provided by the Library.
28+
29+
A “Combined Work” is a work produced by combining or linking an
30+
Application with the Library. The particular version of the Library
31+
with which the Combined Work was made is also called the “Linked
32+
Version”.
33+
34+
The “Minimal Corresponding Source” for a Combined Work means the
35+
Corresponding Source for the Combined Work, excluding any source code
36+
for portions of the Combined Work that, considered in isolation, are
37+
based on the Application, and not on the Linked Version.
38+
39+
The “Corresponding Application Code” for a Combined Work means the
40+
object code and/or source code for the Application, including any data
41+
and utility programs needed for reproducing the Combined Work from the
42+
Application, but excluding the System Libraries of the Combined Work.
43+
44+
### 1. Exception to Section 3 of the GNU GPL
45+
46+
You may convey a covered work under sections 3 and 4 of this License
47+
without being bound by section 3 of the GNU GPL.
48+
49+
### 2. Conveying Modified Versions
50+
51+
If you modify a copy of the Library, and, in your modifications, a
52+
facility refers to a function or data to be supplied by an Application
53+
that uses the facility (other than as an argument passed when the
54+
facility is invoked), then you may convey a copy of the modified
55+
version:
56+
57+
* **a)** under this License, provided that you make a good faith effort to
58+
ensure that, in the event an Application does not supply the
59+
function or data, the facility still operates, and performs
60+
whatever part of its purpose remains meaningful, or
61+
62+
* **b)** under the GNU GPL, with none of the additional permissions of
63+
this License applicable to that copy.
64+
65+
### 3. Object Code Incorporating Material from Library Header Files
66+
67+
The object code form of an Application may incorporate material from
68+
a header file that is part of the Library. You may convey such object
69+
code under terms of your choice, provided that, if the incorporated
70+
material is not limited to numerical parameters, data structure
71+
layouts and accessors, or small macros, inline functions and templates
72+
(ten or fewer lines in length), you do both of the following:
73+
74+
* **a)** Give prominent notice with each copy of the object code that the
75+
Library is used in it and that the Library and its use are
76+
covered by this License.
77+
* **b)** Accompany the object code with a copy of the GNU GPL and this license
78+
document.
79+
80+
### 4. Combined Works
81+
82+
You may convey a Combined Work under terms of your choice that,
83+
taken together, effectively do not restrict modification of the
84+
portions of the Library contained in the Combined Work and reverse
85+
engineering for debugging such modifications, if you also do each of
86+
the following:
87+
88+
* **a)** Give prominent notice with each copy of the Combined Work that
89+
the Library is used in it and that the Library and its use are
90+
covered by this License.
91+
92+
* **b)** Accompany the Combined Work with a copy of the GNU GPL and this license
93+
document.
94+
95+
* **c)** For a Combined Work that displays copyright notices during
96+
execution, include the copyright notice for the Library among
97+
these notices, as well as a reference directing the user to the
98+
copies of the GNU GPL and this license document.
99+
100+
* **d)** Do one of the following:
101+
- **0)** Convey the Minimal Corresponding Source under the terms of this
102+
License, and the Corresponding Application Code in a form
103+
suitable for, and under terms that permit, the user to
104+
recombine or relink the Application with a modified version of
105+
the Linked Version to produce a modified Combined Work, in the
106+
manner specified by section 6 of the GNU GPL for conveying
107+
Corresponding Source.
108+
- **1)** Use a suitable shared library mechanism for linking with the
109+
Library. A suitable mechanism is one that **(a)** uses at run time
110+
a copy of the Library already present on the user's computer
111+
system, and **(b)** will operate properly with a modified version
112+
of the Library that is interface-compatible with the Linked
113+
Version.
114+
115+
* **e)** Provide Installation Information, but only if you would otherwise
116+
be required to provide such information under section 6 of the
117+
GNU GPL, and only to the extent that such information is
118+
necessary to install and execute a modified version of the
119+
Combined Work produced by recombining or relinking the
120+
Application with a modified version of the Linked Version. (If
121+
you use option **4d0**, the Installation Information must accompany
122+
the Minimal Corresponding Source and Corresponding Application
123+
Code. If you use option **4d1**, you must provide the Installation
124+
Information in the manner specified by section 6 of the GNU GPL
125+
for conveying Corresponding Source.)
126+
127+
### 5. Combined Libraries
128+
129+
You may place library facilities that are a work based on the
130+
Library side by side in a single library together with other library
131+
facilities that are not Applications and are not covered by this
132+
License, and convey such a combined library under terms of your
133+
choice, if you do both of the following:
134+
135+
* **a)** Accompany the combined library with a copy of the same work based
136+
on the Library, uncombined with any other library facilities,
137+
conveyed under the terms of this License.
138+
* **b)** Give prominent notice with the combined library that part of it
139+
is a work based on the Library, and explaining where to find the
140+
accompanying uncombined form of the same work.
141+
142+
### 6. Revised Versions of the GNU Lesser General Public License
143+
144+
The Free Software Foundation may publish revised and/or new versions
145+
of the GNU Lesser General Public License from time to time. Such new
146+
versions will be similar in spirit to the present version, but may
147+
differ in detail to address new problems or concerns.
148+
149+
Each version is given a distinguishing version number. If the
150+
Library as you received it specifies that a certain numbered version
151+
of the GNU Lesser General Public License “or any later version”
152+
applies to it, you have the option of following the terms and
153+
conditions either of that published version or of any later version
154+
published by the Free Software Foundation. If the Library as you
155+
received it does not specify a version number of the GNU Lesser
156+
General Public License, you may choose any version of the GNU Lesser
157+
General Public License ever published by the Free Software Foundation.
158+
159+
If the Library as you received it specifies that a proxy can decide
160+
whether future versions of the GNU Lesser General Public License shall
161+
apply, that proxy's public statement of acceptance of any version is
162+
permanent authorization for you to choose that version for the
163+
Library.

composer.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,11 @@
1717
"psr-4": {
1818
"HeimrichHannot\\SalutationCreator\\": "src/"
1919
}
20+
},
21+
"require-dev": {
22+
"rector/rector": "^2.2",
23+
"symplify/easy-coding-standard": "^13.0",
24+
"phpstan/phpstan": "^2.1",
25+
"phpstan/phpstan-symfony": "^2.0"
2026
}
21-
}
27+
}

ecs.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use PhpCsFixer\Fixer\Basic\BracesPositionFixer;
6+
use PhpCsFixer\Fixer\Import\NoUnusedImportsFixer;
7+
use PhpCsFixer\Fixer\Operator\NotOperatorWithSuccessorSpaceFixer;
8+
use PhpCsFixer\Fixer\Whitespace\MethodChainingIndentationFixer;
9+
use Symplify\EasyCodingStandard\Config\ECSConfig;
10+
11+
return ECSConfig::configure()
12+
->withPaths([
13+
__DIR__ . '/src',
14+
// __DIR__ . '/contao',
15+
16+
])
17+
18+
// add a single rule
19+
->withRules([
20+
NoUnusedImportsFixer::class,
21+
BracesPositionFixer::class,
22+
])
23+
24+
// add sets - group of rules
25+
->withPreparedSets(
26+
arrays: true,
27+
comments: true,
28+
docblocks: true,
29+
spaces: true,
30+
namespaces: true,
31+
)
32+
->withPhpCsFixerSets(symfony: true)
33+
->withSkip([
34+
NotOperatorWithSuccessorSpaceFixer::class,
35+
MethodChainingIndentationFixer::class => [
36+
'*/DependencyInjection/Configuration.php',
37+
],
38+
]);

phpstan.neon

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
parameters:
2+
level: 1
3+
paths:
4+
- src
5+
# - contao
6+
# universalObjectCratesClasses:
7+
# - Contao\Model
8+
# - Contao\Template
9+
includes:
10+
- vendor/phpstan/phpstan-symfony/extension.neon

rector.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Contao\Rector\Set\ContaoLevelSetList;
6+
use Contao\Rector\Set\ContaoSetList;
7+
use Rector\Config\RectorConfig;
8+
use Rector\Php84\Rector\Param\ExplicitNullableParamTypeRector;
9+
use Rector\Set\ValueObject\LevelSetList;
10+
use Rector\TypeDeclaration\Rector\ClassMethod\AddVoidReturnTypeWhereNoReturnRector;
11+
use Rector\ValueObject\PhpVersion;
12+
13+
return RectorConfig::configure()
14+
->withPaths([
15+
__DIR__ . '/src',
16+
17+
])
18+
->withPhpVersion(PhpVersion::PHP_84)
19+
->withRules([
20+
AddVoidReturnTypeWhereNoReturnRector::class,
21+
ExplicitNullableParamTypeRector::class,
22+
])
23+
24+
->withImportNames(
25+
importShortClasses: false,
26+
removeUnusedImports: true
27+
)
28+
->withComposerBased(
29+
symfony: true,
30+
)
31+
->withSets([
32+
LevelSetList::UP_TO_PHP_81,
33+
])
34+
;

src/Context/Gender/Gender.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public static function tryFromString(string $value, ?self $fallback = null, ?arr
5454
return $result;
5555
}
5656

57-
$mapping = $mapping ?? self::defaultMapping();
57+
$mapping ??= self::defaultMapping();
5858

5959
return $mapping[$value] ?? $fallback;
6060
}

0 commit comments

Comments
 (0)