Skip to content
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
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,11 @@ vendor/
.php-cs-fixer.cache

### PHPUnit template
# Generated files
.phpunit.result.cache
.phpunit.cache
.phpunit.cache/

### PHP Mess Detector
.phpmd.result-cache.php


### Custom
Expand Down
127 changes: 74 additions & 53 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

declare(strict_types=1);

$headerProjName = 'ezkoding';
$headerProjName = 'ezkoding';
$headerProjAuthor = 'Oliver Glowa, coding.glowa.com';
$headerProjYear = 2025;
$headerText = <<<EOF
$headerProjYear = 2025;
$headerText = <<<EOF
This file is part of ${headerProjName}

(c) ${headerProjYear} ${headerProjAuthor}
Expand All @@ -16,26 +16,27 @@

$projRules = [
// Rulsets
'@PSR2' => true,
'@PSR12' => true,
'@PSR2' => true,
'@PSR12' => true,
'@PHP8x4Migration' => true,
// Customizing
'declare_strict_types' => true,
'no_trailing_comma_in_singleline' => true,
'no_unused_imports' => true,
'protected_to_private' => false,
'modifier_keywords' => true,
'return_assignment' => true,
'declare_strict_types' => true,
'no_trailing_comma_in_singleline' => true,
'no_unused_imports' => true,
'protected_to_private' => false,
'modifier_keywords' => true,
'return_assignment' => true,
// Blank lines / spacing
'class_attributes_separation' => [
'class_attributes_separation' => [
'elements' => [
'const' => 'one',
'method' => 'one',
'property' => 'one',
'const' => 'one',
'method' => 'one',
'property' => 'one',
'trait_import' => 'none',
'case' => 'none'
'case' => 'none'
]
],
'blank_line_before_statement' => [
'blank_line_before_statement' => [
'statements' => [
'declare',
'exit',
Expand All @@ -48,7 +49,8 @@
'try'
]
],
'no_extra_blank_lines' => [
'no_unused_imports' => true,
'no_extra_blank_lines' => [
'tokens' => [
'attribute',
'break',
Expand All @@ -65,20 +67,29 @@
'throw'
]
],
'statement_indentation' => ['stick_comment_to_next_continuous_control_statement' => true],
'ordered_imports' => [
'imports_order' => ['class', 'function', 'const'],
'sort_algorithm' => 'alpha'
],
'single_import_per_statement' => [
'group_to_single_imports' => true
],
'statement_indentation' => ['stick_comment_to_next_continuous_control_statement' => true],
// Comments
'multiline_comment_opening_closing' => true,
'no_empty_comment' => true,
'single_line_comment_spacing' => true,
'single_line_comment_style' => true,
'align_multiline_comment' => ['comment_type' => 'phpdocs_like'],
'multiline_comment_opening_closing' => true,
'no_empty_comment' => true,
'single_line_comment_spacing' => true,
'single_line_comment_style' => true,
'align_multiline_comment' => ['comment_type' => 'phpdocs_like'],
// PHPDoc
'no_blank_lines_after_phpdoc' => true,
'no_empty_phpdoc' => true,
'phpdoc_add_missing_param_annotation' => true,
'phpdoc_align' => [
'no_blank_lines_after_phpdoc' => true,
'no_empty_phpdoc' => true,
'phpdoc_add_missing_param_annotation' => [
'only_untyped' => false,
],
'phpdoc_align' => [
'align' => 'vertical',
'tags' => [
'tags' => [
'method',
'param',
'property',
Expand Down Expand Up @@ -107,20 +118,21 @@
'psalm-method'
]
],
'phpdoc_annotation_without_dot' => true,
'phpdoc_indent' => true,
'phpdoc_inline_tag_normalizer' => true,
'phpdoc_line_span' => ['property' => 'single', 'const' => 'single', 'method' => 'multi'],
'phpdoc_no_access' => true,
'phpdoc_no_alias_tag' => true,
'phpdoc_no_empty_return' => true,
'phpdoc_no_package' => true,
'phpdoc_no_useless_inheritdoc' => true,
'phpdoc_order' => ['order' => ['param', 'return', 'throws']],
'phpdoc_param_order' => true,
'phpdoc_return_self_reference' => true,
'phpdoc_scalar' => true,
'phpdoc_separation' => [
'phpdoc_annotation_without_dot' => true,
'phpdoc_indent' => true,
'phpdoc_inline_tag_normalizer' => true,
'phpdoc_line_span' => ['property' => 'single', 'const' => 'single', 'method' => 'multi'],
'phpdoc_no_access' => true,
'phpdoc_no_alias_tag' => true,
'phpdoc_no_duplicate_types' => true,
'phpdoc_no_empty_return' => true,
'phpdoc_no_package' => true,
'phpdoc_no_useless_inheritdoc' => true,
'phpdoc_order' => ['order' => ['param', 'return', 'throws']],
'phpdoc_param_order' => true,
'phpdoc_return_self_reference' => true,
'phpdoc_scalar' => true,
'phpdoc_separation' => [
'groups' => [
['author', 'copyright', 'license'],
['category', 'package', 'subpackage'],
Expand All @@ -129,17 +141,26 @@
['psalm-suppress', 'phpstan-ignore']
],
],
'phpdoc_single_line_var_spacing' => true,
'phpdoc_summary' => true,
'phpdoc_tag_type' => true,
'phpdoc_to_comment' => ['ignored_tags' => ['phpstan-ignore', 'psalm-suppress']],
'phpdoc_single_line_var_spacing' => true,
'phpdoc_summary' => true,
'phpdoc_tag_casing' => true,
'phpdoc_tag_type' => true,
'phpdoc_to_comment' => ['ignored_tags' => ['phpstan-ignore', 'psalm-suppress']],
'phpdoc_trim_consecutive_blank_line_separation' => true,
'phpdoc_trim' => true,
'phpdoc_types' => true,
'phpdoc_types_order' => true,
'phpdoc_var_annotation_correct_order' => true,
'phpdoc_var_without_name' => true,
'header_comment' => ['header' => $headerText]
'phpdoc_trim' => true,
'phpdoc_types' => true,
'phpdoc_types_order' => true,
'phpdoc_var_annotation_correct_order' => true,
'phpdoc_var_without_name' => true,
// Risky
/*
'@PHP8x2Migration:risky' => true,
'phpdoc_to_param_type' =>true,
'phpdoc_to_property_type' =>true,
'phpdoc_to_return_type' => true,
*/
// Header
'header_comment' => ['header' => $headerText]
];

$finder = PhpCsFixer\Finder::create()->in(__DIR__ . '/src')->in(__DIR__ . '/tests');
Expand Down
40 changes: 36 additions & 4 deletions .phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@

<autoload>/vendor/autoload.php</autoload>

<!-- Default rulesets -->
<rule ref="PSR2"/>
<rule ref="PSR12"/>

<!-- Overrides -->
<rule ref="PSR2.ControlStructures.SwitchDeclaration">
<exclude name="PSR2.ControlStructures.SwitchDeclaration.WrongOpenercase"/>
<exclude name="PSR2.ControlStructures.SwitchDeclaration.WrongOpenerdefault"/>
</rule>

<!-- Generic -->
<!-- Default line length in my projects -->
<rule ref="Generic.Files.LineLength">
<properties>
Expand All @@ -38,6 +37,25 @@
<property name="ignoreComments" value="true"/>
</properties>
</rule>
<rule ref="Generic.Arrays.DisallowLongArraySyntax" />
<rule ref="Generic.Metrics.CyclomaticComplexity">
<properties>
<property name="complexity" value="20" />
<property name="absoluteComplexity" value="20" />
</properties>
</rule>
<rule ref="Generic.PHP.ForbiddenFunctions">
<properties>
<property name="error" value="true" />
</properties>
</rule>
<rule ref="Generic.WhiteSpace.ScopeIndent">
<properties>
<property name="exact" value="true" />
</properties>
</rule>

<!-- PSR1 -->
<!-- Ignore bootstrap file in test classes -->
<rule ref="PSR1.Files.SideEffects.FoundWithSymbols">
<exclude-pattern>tests/**/*Test\.php</exclude-pattern>
Expand All @@ -46,6 +64,20 @@
<rule ref="PSR1.Methods.CamelCapsMethodName">
<exclude name="PSR1.Methods.CamelCapsMethodName.NotCamelCaps"/>
</rule>

<!-- PSR2 -->
<rule ref="PSR2.ControlStructures.SwitchDeclaration">
<exclude name="PSR2.ControlStructures.SwitchDeclaration.WrongOpenercase"/>
<exclude name="PSR2.ControlStructures.SwitchDeclaration.WrongOpenerdefault"/>
</rule>

<!-- Squiz -->
<rule ref="Squiz.Functions.MultiLineFunctionDeclaration.CloseBracketNewLine" />
<rule ref="Squiz.Functions.MultiLineFunctionDeclaration.FirstParamSpacing" />
<rule ref="Squiz.Functions.MultiLineFunctionDeclaration.OneParamPerLine" />
<rule ref="Squiz.PHP.CommentedOutCode" />

<!-- Internal -->
<!--
There is a special internal error message produced by PHP_CodeSniffer
when it is unable to detect code in a file, possible due to
Expand Down
20 changes: 11 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"minimum-stability": "stable",
"prefer-stable": true,
"require": {
"php": ">=7.4",
"php": ">=8.4.1",
"php-ds/php-ds": "^1.0",
"psr/log": "^1.0||^2.0||^3.0",
"composer/composer": "^2.0"
Expand All @@ -44,19 +44,19 @@
"hrodic/php-integration-testing": "Integration Testing with PHPUnit"
},
"require-dev": {
"phpunit/phpunit": "^9.6",
"phpunit/phpunit": "^13.1",
"phpstan/phpstan": "^2.1",
"phpstan/phpstan-strict-rules": "^2.0",
"vimeo/psalm": "^5.26",
"vimeo/psalm": "^6.0",
"psalm/plugin-phpunit": "^0.19",
"friendsofphp/php-cs-fixer": "^3.0",
"squizlabs/php_codesniffer": "^3.13",
"squizlabs/php_codesniffer": "^4.0",
"phpmd/phpmd": "^2.0",
"rogervila/php-sonarqube-scanner": "^1.0"
},
"config": {
"platform": {
"php": "7.4.0"
"php": "8.4.3"
},
"optimize-autoloader": false,
"sort-packages": true,
Expand Down Expand Up @@ -101,22 +101,24 @@
],
"c-package": "@composer archive --format=zip --dir=target/staging",
"c-phpcs": [
"bash -c 'echo PHP Code Sniffer checking ...'",
"bash -c 'mkdir --p target/analysis/phpcs'",
"bash -c 'rm -f target/analysis/phpcs/phpcsniffer-report.txt'",
"@php -d xdebug.mode=off vendor/bin/phpcs --colors || true",
"bash -c 'if [ -s target/analysis/phpcs/phpcsniffer-report.txt ]; then cat target/analysis/phpcs/phpcsniffer-report.txt; exit 0; else exit 0; fi'"
],
"c-phpcbf": [
"bash -c 'echo PHP Code Sniffer FIXING ...'",
"bash -c 'mkdir --p target/analysis/phpcs'",
"bash -c 'rm -f target/analysis/phpcs/phpcsniffer-report.txt'",
"@php -d xdebug.mode=off vendor/bin/phpcbf || true",
"bash -c 'if [ -s target/analysis/phpcs/phpcsniffer-report.txt ]; then cat target/analysis/phpcs/phpcsniffer-report.txt; exit 0; else exit 0; fi'"
],
"c-phpdoc": "phpDocumentor run",
"c-phpmd": [
"bash -c 'echo PHP Mess Dectector running...'",
"bash -c 'echo PHP Mess Dectector running ...'",
"bash -c 'rm -f target/analysis/phpmd/phpmd-report.txt'",
"@php -d xdebug.mode=off vendor/bin/phpmd src,tests text .phpmd.xml.dist --report-file=target/analysis/phpmd/phpmd-report.txt -v --color --ignore-errors-on-exit --ignore-violations-on-exit",
"@php -d xdebug.mode=off vendor/bin/phpmd src,tests text .phpmd.xml.dist --report-file=target/analysis/phpmd/phpmd-report.txt --error-file=target/analysis/phpmd/zzz-phpmd-error.txt --color --cache --ignore-errors-on-exit --ignore-violations-on-exit",
"bash -c 'if [ -s target/analysis/phpmd/phpmd-report.txt ]; then cat target/analysis/phpmd/phpmd-report.txt; exit 1; else exit 0; fi'"
],
"c-phpstan": "@php -d xdebug.mode=off vendor/bin/phpstan analyse",
Expand All @@ -127,7 +129,7 @@
"composer c-test",
"@php -d xdebug.mode=off -Dproject.settings=sonar-project.properties vendor/bin/sonar-scanner"
],
"c-test": "@php -d xdebug.mode=coverage vendor/bin/phpunit"
"c-test": "@php -d xdebug.mode=coverage vendor/bin/phpunit -c phpunit.xml.cov"
},
"scripts-descriptions": {
"c-all": "CUSTOM: Run composer with c-check, c-test, c-format",
Expand All @@ -137,7 +139,7 @@
"c-format": "CUSTOM: Format the code with c-fix, c-phpcbf",
"c-fix": "CUSTOM: PHP CS Fixer fixes your code",
"c-package": "CUSTOM: Create deployable package",
"c-phpcs": "CUSTOM: PHP Code Sniffer verifies your code",
"c-phpcs": "CUSTOM: See what PHP Code Sniffer will fix (dry-run)",
"c-phpcbf": "CUSTOM: PHP Code Sniffer fixes your code",
"c-phpdoc": "CUSTOM: phpDocumentor generates the API documentation",
"c-phpmd": "CUSTOM: PHP Mess Detector verifies your code",
Expand Down
Loading
Loading