Skip to content

Commit 9b032da

Browse files
PatrickJanzenrdss-sknottrdss-pkuehn
authored
php8.4 (#41)
* Small PHP8.4 feature port * Ignore error that arrays are not a callable * Update php action * Fix safe version 3 compatibility * Replace deprecated Sniff * Replace rules from phpmd by phpstan and phpcs * Added annotations where needed * Modify autoload trigger for Tokens Class * Letting users know what went wrong with safe * Pin the execution order to get more comparable infection results --------- Co-authored-by: Sebastian Knott <sebastian.knott@rewe-digital.com> Co-authored-by: Peter Kuehn <peter.kuehn@rewe-digital.com>
1 parent b18fdb8 commit 9b032da

File tree

175 files changed

+2620
-748
lines changed

Some content is hidden

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

175 files changed

+2620
-748
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ jobs:
4545
${{ runner.os }}-codestyle-${{ env.cache-name }}-
4646
4747
- name: Setup PHP and Composer
48-
uses: shivammathur/setup-php@a4e22b60bbb9c1021113f2860347b0759f66fe5d
48+
uses: shivammathur/setup-php@e77cdb393f70751e0417891f9ae9de6a41096210
4949
with:
50-
php-version: '8.2'
50+
php-version: '8.4'
5151
extensions: gd
5252
tools: cs2pr, composer
5353
env:
@@ -118,9 +118,9 @@ jobs:
118118
${{ runner.os }}-tests-${{ env.cache-name }}-
119119
120120
- name: Setup PHP and Composer
121-
uses: shivammathur/setup-php@a4e22b60bbb9c1021113f2860347b0759f66fe5d
121+
uses: shivammathur/setup-php@e77cdb393f70751e0417891f9ae9de6a41096210
122122
with:
123-
php-version: '8.2'
123+
php-version: '8.4'
124124
tools: composer:${{ matrix.composer_version }}
125125
extensions: xdebug
126126
env:

Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
FROM php:8.2-cli-alpine
1+
FROM php:8.4-cli-alpine
22

33
RUN set -eux ; \
4-
apk add --no-cache --virtual .composer-rundeps \
4+
apk add --update --no-cache --virtual .composer-rundeps \
55
bash \
66
coreutils \
77
git \
88
nodejs \
99
npm \
1010
openssh-client \
11+
sqlite-dev \
1112
tini \
1213
unzip \
1314
zip \

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ Coding Standard.
1313
It incorporates
1414
* [PHP Code Sniffer](https://github.com/squizlabs/PHP_CodeSniffer)
1515
and its configuration
16-
* [PHP Mess Detector](https://github.com/phpmd/phpmd) and its configuration
1716
* [PHP Copy Paste Detector](https://github.com/sebastianbergmann/phpcpd)
1817
* [PHP-Parallel-Lint](https://github.com/JakubOnderka/PHP-Parallel-Lint)
1918
* [PHPStan - PHP Static Analysis Tool](https://github.com/phpstan/phpstan)

composer.json

Lines changed: 113 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -1,118 +1,118 @@
11
{
2-
"name": "zooroyal/coding-standard-source",
3-
"description": "This is the ZooRoyal coding standard source package.",
4-
"type": "phpcodesniffer-standard",
5-
"keywords": [
6-
"ZooRoyal",
7-
"phpcs",
8-
"standards",
9-
"phpmd",
10-
"phpcpd",
11-
"lint"
12-
],
13-
"homepage": "https://github.com/ZooRoyal/coding-standard-source",
14-
"license": "BSD-3-Clause",
15-
"authors": [
16-
{
17-
"name": "Sebastian Knott",
18-
"email": "sebastian.knott@rewe-digital.com"
19-
}
20-
],
21-
"support": {
22-
"issues": "https://github.com/ZooRoyal/coding-standard-source/issues",
23-
"wiki": "https://github.com/ZooRoyal/coding-standard-source/wiki",
24-
"source": "https://github.com/ZooRoyal/coding-standard-source"
25-
},
26-
"require": {
27-
"php": "^8.2.0",
28-
"ext-json": "*",
29-
"ext-xml": "*",
30-
"composer-runtime-api": "^2.0",
31-
"bamarni/composer-bin-plugin": "^1.8",
32-
"composer/semver": "^3.4",
33-
"dealerdirect/phpcodesniffer-composer-installer": "^1.0.0",
34-
"nette/neon": "^3.3",
35-
"nikic/php-parser": "^4.18",
36-
"php-di/php-di": "^7.0.1",
37-
"phpcompatibility/php-compatibility": "dev-develop#a8d67148fb990fbf5c2f6166d54bc91cc01fc655",
38-
"slevomat/coding-standard": "^8.10.0",
39-
"squizlabs/php_codesniffer": "^3.9.0",
40-
"symfony/console": " ^6.2.8",
41-
"symfony/event-dispatcher": "^6.2.2",
42-
"symfony/filesystem": " ^6.2.0",
43-
"symfony/process": " ^6.2.0",
44-
"thecodingmachine/safe": "^2.5",
45-
"webmozart/path-util": "^2.3"
46-
},
47-
"require-dev": {
48-
"amphp/amp": "^v2.6.2",
49-
"amphp/phpunit-util": "^2.0.0",
50-
"amphp/process": "^v1.1.4",
51-
"brianium/paratest": "^6.11.0",
52-
"infection/infection": ">=0.27.11",
53-
"mockery/mockery": "^1.6.7",
54-
"phpunit/phpunit": "^9.6.16",
55-
"roave/security-advisories": "dev-latest",
56-
"sebastianknott/hamcrest-object-accessor": "^3.0.0"
57-
},
58-
"replace": {
59-
"zooroyal/coding-standard": "self.version"
60-
},
61-
"autoload": {
62-
"psr-4": {
63-
"Zooroyal\\CodingStandard\\": "src/main/php/"
64-
}
65-
},
66-
"autoload-dev": {
67-
"psr-4": {
68-
"Zooroyal\\CodingStandard\\Tests\\": "tests/"
69-
},
70-
"files": [
71-
"vendor/squizlabs/php_codesniffer/autoload.php",
72-
"vendor/squizlabs/php_codesniffer/src/Util/Tokens.php",
73-
"vendor/squizlabs/php_codesniffer/src/Sniffs/Sniff.php",
74-
"vendor/slevomat/coding-standard/autoload-bootstrap.php"
75-
]
76-
},
77-
"bin": [
78-
"src/bin/coding-standard"
79-
],
80-
"scripts": {
81-
"post-update-cmd": "npm update",
82-
"post-install-cmd": "npm install",
83-
"ci": [
84-
"@test-prepare",
85-
"@test",
86-
"@infection-command"
2+
"name": "zooroyal/coding-standard-source",
3+
"description": "This is the ZooRoyal coding standard source package.",
4+
"type": "phpcodesniffer-standard",
5+
"keywords": [
6+
"ZooRoyal",
7+
"phpcs",
8+
"standards",
9+
"phpcpd",
10+
"lint"
8711
],
88-
"test-mkdirs": "mkdir -p tmp/phpunit",
89-
"test-paratest-command": "paratest -p$(getconf _NPROCESSORS_ONLN)",
90-
"test-prepare": "mkdir -p tmp/phpunit",
91-
"test": [
92-
"@test-prepare",
93-
"@test-paratest-command"
12+
"homepage": "https://github.com/ZooRoyal/coding-standard-source",
13+
"license": "BSD-3-Clause",
14+
"authors": [
15+
{
16+
"name": "Sebastian Knott",
17+
"email": "sebastian.knott@rewe-digital.com"
18+
}
9419
],
95-
"infection-command": "infection -n --threads=$(getconf _NPROCESSORS_ONLN) --skip-initial-tests --coverage=tmp/phpunit --no-progress",
96-
"infection": [
97-
"@test-prepare",
98-
"@test --testsuite=InfectionRelevant",
99-
"@infection-command"
100-
]
101-
},
102-
"config": {
103-
"optimize-autoloader": true,
104-
"sort-packages": true,
105-
"process-timeout": 600,
106-
"allow-plugins": {
107-
"dealerdirect/phpcodesniffer-composer-installer": true,
108-
"infection/extension-installer": true,
109-
"bamarni/composer-bin-plugin": true
110-
}
111-
},
112-
"extra": {
113-
"bamarni-bin": {
114-
"bin-links": true,
115-
"forward-command": true
20+
"support": {
21+
"issues": "https://github.com/ZooRoyal/coding-standard-source/issues",
22+
"wiki": "https://github.com/ZooRoyal/coding-standard-source/wiki",
23+
"source": "https://github.com/ZooRoyal/coding-standard-source"
24+
},
25+
"require": {
26+
"php": "^8.4.0",
27+
"ext-json": "*",
28+
"ext-xml": "*",
29+
"composer-runtime-api": "^2.0",
30+
"bamarni/composer-bin-plugin": "^1.8.2",
31+
"composer/semver": "^3.4.3",
32+
"dealerdirect/phpcodesniffer-composer-installer": "^1.0.0",
33+
"nette/neon": "^3.4.4",
34+
"nette/utils": "^4.0.5",
35+
"nikic/php-parser": "^5.4.0",
36+
"php-di/php-di": "^7.0.1",
37+
"slevomat/coding-standard": "^8.16.1",
38+
"squizlabs/php_codesniffer": "^3.12.0",
39+
"symfony/console": " ^7.2.1",
40+
"symfony/event-dispatcher": "^7.2.0",
41+
"symfony/filesystem": " ^7.2.0",
42+
"symfony/process": " ^7.2.4",
43+
"thecodingmachine/safe": "^3.0.2",
44+
"webmozart/path-util": "^2.3"
45+
},
46+
"require-dev": {
47+
"amphp/amp": "^v2.6.2",
48+
"amphp/phpunit-util": "^2.0.1",
49+
"amphp/process": "^v1.1.9",
50+
"brianium/paratest": "^v6.11.1",
51+
"infection/infection": ">=0.29.14",
52+
"mikey179/vfsstream": "^1.6.12",
53+
"mockery/mockery": "1.6.11",
54+
"phpunit/phpunit": "^9.6.22",
55+
"roave/security-advisories": "dev-latest",
56+
"sebastianknott/hamcrest-object-accessor": "^3.0.0"
57+
},
58+
"replace": {
59+
"zooroyal/coding-standard": "self.version"
60+
},
61+
"autoload": {
62+
"psr-4": {
63+
"Zooroyal\\CodingStandard\\": "src/main/php/"
64+
}
65+
},
66+
"autoload-dev": {
67+
"psr-4": {
68+
"Zooroyal\\CodingStandard\\Tests\\": "tests/"
69+
},
70+
"files": [
71+
"vendor/squizlabs/php_codesniffer/autoload.php",
72+
"vendor/squizlabs/php_codesniffer/src/Util/Tokens.php",
73+
"vendor/squizlabs/php_codesniffer/src/Sniffs/Sniff.php",
74+
"vendor/slevomat/coding-standard/autoload-bootstrap.php"
75+
]
76+
},
77+
"bin": [
78+
"src/bin/coding-standard"
79+
],
80+
"scripts": {
81+
"post-update-cmd": "npm update",
82+
"post-install-cmd": "npm install",
83+
"ci": [
84+
"@test-prepare",
85+
"@test",
86+
"@infection-command"
87+
],
88+
"test-mkdirs": "mkdir -p tmp/phpunit",
89+
"test-paratest-command": "paratest -p$(getconf _NPROCESSORS_ONLN)",
90+
"test-prepare": "mkdir -p tmp/phpunit",
91+
"test": [
92+
"@test-prepare",
93+
"@test-paratest-command"
94+
],
95+
"infection-command": "infection -n --threads=$(getconf _NPROCESSORS_ONLN) --skip-initial-tests --coverage=tmp/phpunit --no-progress",
96+
"infection": [
97+
"@test-prepare",
98+
"@test-paratest-command --testsuite=InfectionRelevant",
99+
"@infection-command"
100+
]
101+
},
102+
"config": {
103+
"optimize-autoloader": true,
104+
"sort-packages": true,
105+
"process-timeout": 600,
106+
"allow-plugins": {
107+
"dealerdirect/phpcodesniffer-composer-installer": true,
108+
"infection/extension-installer": true,
109+
"bamarni/composer-bin-plugin": true
110+
}
111+
},
112+
"extra": {
113+
"bamarni-bin": {
114+
"bin-links": true,
115+
"forward-command": true
116+
}
116117
}
117-
}
118118
}

config/phpcs/ZooRoyal/ruleset.xml

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,8 @@
1212
<exclude name="PSR1.Files.SideEffects.FoundWithSymbols" />
1313
</rule>
1414

15-
<rule ref="PHPCompatibility">
16-
<!-- Sniff generates false positives if classname is used in another namespace -->
17-
<exclude name="PHPCompatibility.Classes.NewClasses.attributeFound"/>
18-
<exclude name="PHPCompatibility.Attributes.NewAttributes.Found"/>
19-
</rule>
20-
2115
<!-- Custom Rule-->
16+
<rule ref="../../../src/main/php/Sniffs/ObjectCalisthenics/Standards/ZooRoyal"/>
2217
<rule ref="../../../src/main/php/Sniffs/PHPCodeSniffer/Standards/ZooRoyal"/>
2318
<rule ref="../../../src/main/php/Sniffs/Rdss/Standards/ZooRoyal"/>
2419

@@ -78,15 +73,17 @@
7873
<rule ref="Generic.Functions.CallTimePassByReference"/>
7974
<rule ref="Generic.Functions.FunctionCallArgumentSpacing"/>
8075
<rule ref="Generic.Metrics.NestingLevel"/>
76+
<rule ref="Generic.Metrics.CyclomaticComplexity"/>
8177
<rule ref="Generic.NamingConventions.ConstructorName"/>
8278
<rule ref="Generic.NamingConventions.UpperCaseConstantName"/>
8379
<rule ref="Generic.PHP.CharacterBeforePHPOpeningTag"/>
8480
<rule ref="Generic.PHP.DeprecatedFunctions"/>
81+
<rule ref="Generic.PHP.DiscourageGoto"/>
8582
<rule ref="Generic.PHP.ForbiddenFunctions">
8683
<properties>
8784
<property name="forbiddenFunctions"
8885
type="array"
89-
value="sizeof=>count,delete=>unset,print=>echo,is_null=>null,create_function=>null,ob_end_flush=>null,chop=>rtrim,close=>closedir,die=>exit,diskfreespace=>disk_free_space,doubleval=>floatval,fputs=>fwrite,gzputs=>gzwrite,i18n_convert=>mb_convert_encoding,i18n_discover_encoding=>mb_detect_encoding,i18n_http_input=>mb_http_input,i18n_http_output=>mb_http_output,i18n_internal_encoding=>mb_internal_encoding,i18n_ja_jp_hantozen=>mb_convert_kana,i18n_mime_header_decode=>mb_decode_mimeheader,i18n_mime_header_encode=>mb_encode_mimeheader,imap_create=>imap_createmailbox,imap_fetchtext=>imap_body,imap_getmailboxes=>imap_list_full,imap_getsubscribed=>imap_lsub_full,imap_header=>imap_headerinfo,imap_listmailbox=>imap_list,imap_listsubscribed=>imap_lsub,imap_rename=>imap_renamemailbox,imap_scan=>imap_listscan,imap_scanmailbox=>imap_listscan,ini_alter=>ini_set,is_double=>is_float,is_integer=>is_int,is_long=>is_int,is_real=>is_float,is_writeable=>is_writable,join=>implode,key_exists=>array_key_exists,ldap_close=>ldap_unbind,magic_quotes_runtime=>set_magic_quotes_runtime,mbstrcut=>mb_strcut,mbstrlen=>mb_strlen,mbstrpos=>mb_strpos,mbstrrpos=>mb_strrpos,mbsubstr=>mb_substr,mysql=>mysql_db_query,mysql_createdb=>mysql_create_db,mysql_db_name=>mysql_result,mysql_dbname=>mysql_result,mysql_dropdb=>mysql_drop_db,mysql_fieldflags=>mysql_field_flags,mysql_fieldlen=>mysql_field_len,mysql_fieldname=>mysql_field_name,mysql_fieldtable=>mysql_field_table,mysql_fieldtype=>mysql_field_type,mysql_freeresult=>mysql_free_result,mysql_listdbs=>mysql_list_dbs,mysql_listfields=>mysql_list_fields,mysql_listtables=>mysql_list_tables,mysql_numfields=>mysql_num_fields,mysql_numrows=>mysql_num_rows,mysql_selectdb=>mysql_select_db,mysql_tablename=>mysql_result,odbc_do=>odbc_exec,odbc_field_precision=>odbc_field_len,pdf_add_outline=>pdf_add_bookmark,pg_clientencoding=>pg_client_encoding,pg_setclientencoding=>pg_set_client_encoding,pos=>current,recode=>recode_string,show_source=>highlight_file,sizeof=>count,snmpwalkoid=>snmprealwalk,strchr=>strstr,xptr_new_context=>xpath_new_context"
86+
value="sizeof=>count,delete=>unset,print=>echo,is_null=>null,create_function=>null,ob_end_flush=>null,chop=>rtrim,close=>closedir,die=>exit,diskfreespace=>disk_free_space,doubleval=>floatval,fputs=>fwrite,gzputs=>gzwrite,i18n_convert=>mb_convert_encoding,i18n_discover_encoding=>mb_detect_encoding,i18n_http_input=>mb_http_input,i18n_http_output=>mb_http_output,i18n_internal_encoding=>mb_internal_encoding,i18n_ja_jp_hantozen=>mb_convert_kana,i18n_mime_header_decode=>mb_decode_mimeheader,i18n_mime_header_encode=>mb_encode_mimeheader,imap_create=>imap_createmailbox,imap_fetchtext=>imap_body,imap_getmailboxes=>imap_list_full,imap_getsubscribed=>imap_lsub_full,imap_header=>imap_headerinfo,imap_listmailbox=>imap_list,imap_listsubscribed=>imap_lsub,imap_rename=>imap_renamemailbox,imap_scan=>imap_listscan,imap_scanmailbox=>imap_listscan,ini_alter=>ini_set,is_double=>is_float,is_integer=>is_int,is_long=>is_int,is_real=>is_float,is_writeable=>is_writable,join=>implode,key_exists=>array_key_exists,ldap_close=>ldap_unbind,magic_quotes_runtime=>set_magic_quotes_runtime,mbstrcut=>mb_strcut,mbstrlen=>mb_strlen,mbstrpos=>mb_strpos,mbstrrpos=>mb_strrpos,mbsubstr=>mb_substr,mysql=>mysql_db_query,mysql_createdb=>mysql_create_db,mysql_db_name=>mysql_result,mysql_dbname=>mysql_result,mysql_dropdb=>mysql_drop_db,mysql_fieldflags=>mysql_field_flags,mysql_fieldlen=>mysql_field_len,mysql_fieldname=>mysql_field_name,mysql_fieldtable=>mysql_field_table,mysql_fieldtype=>mysql_field_type,mysql_freeresult=>mysql_free_result,mysql_listdbs=>mysql_list_dbs,mysql_listfields=>mysql_list_fields,mysql_listtables=>mysql_list_tables,mysql_numfields=>mysql_num_fields,mysql_numrows=>mysql_num_rows,mysql_selectdb=>mysql_select_db,mysql_tablename=>mysql_result,odbc_do=>odbc_exec,odbc_field_precision=>odbc_field_len,pdf_add_outline=>pdf_add_bookmark,pg_clientencoding=>pg_client_encoding,pg_setclientencoding=>pg_set_client_encoding,pos=>current,recode=>recode_string,show_source=>highlight_file,sizeof=>count,snmpwalkoid=>snmprealwalk,strchr=>strstr,xptr_new_context=>xpath_new_context,exit=>null"
9087
/>
9188
</properties>
9289
</rule>
@@ -121,6 +118,11 @@
121118
<rule ref="SlevomatCodingStandard.Attributes.RequireAttributeAfterDocComment"/>
122119
<rule ref="SlevomatCodingStandard.Classes.BackedEnumTypeSpacing"/>
123120
<rule ref="SlevomatCodingStandard.Classes.ClassConstantVisibility"/>
121+
<rule ref="SlevomatCodingStandard.Classes.ClassLength">
122+
<properties>
123+
<property name="maxLinesLength" value="1000" />
124+
</properties>
125+
</rule>
124126
<rule ref="SlevomatCodingStandard.Classes.ClassMemberSpacing"/>
125127
<rule ref="SlevomatCodingStandard.Classes.ClassStructure">
126128
<properties>
@@ -147,6 +149,11 @@
147149
<rule ref="SlevomatCodingStandard.Classes.ModernClassNameReference"/>
148150
<rule ref="SlevomatCodingStandard.Classes.PropertyDeclaration"/>
149151
<rule ref="SlevomatCodingStandard.Classes.RequireConstructorPropertyPromotion"/>
152+
<rule ref="SlevomatCodingStandard.Classes.RequireMultiLineMethodSignature">
153+
<properties>
154+
<property name="minLineLength" value="130"/>
155+
</properties>
156+
</rule>
150157
<rule ref="SlevomatCodingStandard.Commenting.DeprecatedAnnotationDeclaration"/>
151158
<rule ref="SlevomatCodingStandard.Commenting.DisallowCommentAfterCode"/>
152159
<rule ref="SlevomatCodingStandard.Commenting.EmptyComment"/>
@@ -192,7 +199,12 @@
192199
</properties>
193200
</rule>
194201
<rule ref="SlevomatCodingStandard.Functions.DisallowEmptyFunction"/>
195-
<!--<rule ref="SlevomatCodingStandard.Functions.RequireTrailingCommaInCall"/>-->
202+
<rule ref="SlevomatCodingStandard.Functions.FunctionLength">
203+
<properties>
204+
<property name="maxLinesLength" value="39"/>
205+
</properties>
206+
</rule>
207+
<rule ref="SlevomatCodingStandard.Functions.NamedArgumentSpacing"/>
196208
<rule ref="SlevomatCodingStandard.Functions.RequireTrailingCommaInClosureUse"/>
197209
<rule ref="SlevomatCodingStandard.Functions.RequireTrailingCommaInDeclaration"/>
198210
<rule ref="SlevomatCodingStandard.Functions.StaticClosure"/>
@@ -231,13 +243,15 @@
231243
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint"/>
232244
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint"/>
233245
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing"/>
234-
<rule ref="SlevomatCodingStandard.TypeHints.UnionTypeHintFormat">
246+
<rule ref="SlevomatCodingStandard.TypeHints.DNFTypeHintFormat">
235247
<properties>
236-
<property name="withSpaces" type="bool" value="false"/>
248+
<property name="withSpacesAroundOperators" type="bool" value="false"/>
249+
<property name="withSpacesInsideParentheses" type="bool" value="false"/>
237250
<property name="shortNullable" type="bool" value="true"/>
238251
<property name="nullPosition" type="bool" value="last"/>
239252
</properties>
240253
</rule>
254+
<rule ref="SlevomatCodingStandard.Variables.UnusedVariable"/>
241255
<!--
242256
https://packagist.org/packages/bmitch/codor are planed for PHP > 7.0
243257

0 commit comments

Comments
 (0)