Skip to content

Commit

Permalink
Symfony 7 support + update linters rules
Browse files Browse the repository at this point in the history
  • Loading branch information
a-menshchikov committed Jan 5, 2024
1 parent 3bd5b02 commit a620805
Show file tree
Hide file tree
Showing 16 changed files with 191 additions and 166 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
echo "::endgroup::"
- name: Auditor
uses: docker://nbgrp/auditor:0.20.0
uses: docker://nbgrp/auditor:0.23.1

- name: Tests
run: vendor/bin/simple-phpunit
Expand Down
23 changes: 15 additions & 8 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php declare(strict_types=1);
<?php
// SPDX-License-Identifier: BSD-3-Clause

declare(strict_types=1);

return (new PhpCsFixer\Config())
->setFinder(
(new PhpCsFixer\Finder())
Expand All @@ -11,26 +13,26 @@
->setRiskyAllowed(true)
->setRules([
// base presets
'@PER' => true,
'@PER-CS' => true,
'@PhpCsFixer' => true,
'@Symfony' => true,
'@PHP81Migration' => true,

// risky presets
'@PER-CS:risky' => true,
'@PhpCsFixer:risky' => true,
'@Symfony:risky' => true,
'@PHP80Migration:risky' => true,

// presets tuning
'binary_operator_spaces' => [
'operators' => [
'|' => null,
],
],
'blank_line_after_opening_tag' => false,
'blank_line_before_statement' => [
'statements' => ['case', 'default', 'declare', 'return', 'throw', 'try'],
],
'comment_to_phpdoc' => [
'ignored_tags' => [
'phan-suppress-current-line',
'phan-suppress-next-line',
'see',
'todo',
],
Expand Down Expand Up @@ -77,7 +79,11 @@
'null_adjustment' => 'always_last',
'sort_algorithm' => 'none',
],
'single_line_comment_style' => true,
'single_line_comment_style' => [
'comment_types' => [
'asterisk',
],
],
'single_line_throw' => false,
'yoda_style' => false,

Expand All @@ -86,6 +92,7 @@
'final_class' => true,
'header_comment' => [
'header' => 'SPDX-License-Identifier: BSD-3-Clause',
'location' => 'after_open',
'separate' => 'bottom',
],
'nullable_type_declaration_for_default_null_value' => true,
Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
}
],
"require": {
"php": "^7.2 || ^8.0",
"php": "^8.2",
"ext-filter": "*",
"symfony/config": "^5.2 || ^6.0",
"symfony/dependency-injection": "^5.2 || ^6.0",
"symfony/http-kernel": "^5.2 || ^6.0"
"symfony/config": "^7",
"symfony/dependency-injection": "^7",
"symfony/http-kernel": "^7"
},
"require-dev": {
"roave/security-advisories": "dev-latest",
"symfony/phpunit-bridge": "^6.0"
"symfony/phpunit-bridge": "^7"
},
"autoload": {
"psr-4": {
Expand Down
4 changes: 3 additions & 1 deletion grumphp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ grumphp:
phpstan:
use_grumphp_paths: false

psalm: ~
psalm:
no_cache: true
show_info: true

securitychecker_local: ~
174 changes: 93 additions & 81 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,18 @@
</properties>
</rule>

<!-- >>> Functional -->
<!-- >>> Slevomat -->
<rule ref="SlevomatCodingStandard.Arrays.MultiLineArrayEndBracketPlacement" />
<rule ref="SlevomatCodingStandard.Arrays.SingleLineArrayWhitespace">
<properties>
<property name="spacesAroundBrackets" value="0" />
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Arrays.TrailingArrayComma" />

<rule ref="SlevomatCodingStandard.Classes.BackedEnumTypeSpacing" />
<rule ref="SlevomatCodingStandard.Classes.ClassConstantVisibility" />
<rule ref="SlevomatCodingStandard.Classes.ClassMemberSpacing" />
<rule ref="SlevomatCodingStandard.Classes.ClassStructure">
<properties>
<property name="groups" type="array">
Expand Down Expand Up @@ -51,92 +62,22 @@
</property>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Classes.RequireConstructorPropertyPromotion" />
<rule ref="SlevomatCodingStandard.Classes.UselessLateStaticBinding" />
<rule ref="SlevomatCodingStandard.ControlStructures.AssignmentInCondition" />
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowContinueWithoutIntegerOperandInSwitch" />
<rule ref="SlevomatCodingStandard.ControlStructures.EarlyExit">
<properties>
<property name="ignoreStandaloneIfInScope" value="true" />
<property name="ignoreOneLineTrailingIf" value="true" />
<property name="ignoreTrailingIfWithOneInstruction" value="true" />
</properties>
</rule>
<rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceEqualOperator" />
<rule ref="SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly" />
<rule ref="SlevomatCodingStandard.Functions.StaticClosure" />
<rule ref="SlevomatCodingStandard.Functions.StrictCall" />
<rule ref="SlevomatCodingStandard.Functions.ArrowFunctionDeclaration">
<properties>
<property name="allowMultiLine" value="true" />
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Operators.DisallowEqualOperators" />
<rule ref="SlevomatCodingStandard.PHP.DisallowDirectMagicInvokeCall" />
<rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes">
<properties>
<property name="declareOnFirstLine" value="true" />
<property name="linesCountAfterDeclare" value="0" />
<property name="spacesCountAroundEqualsSign" value="0" />
</properties>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint">
<properties>
<property name="enableIntersectionTypeHint" value="false" />
</properties>
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification" />
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.UnionTypeHintFormat">
<properties>
<property name="withSpaces" value="no" />
<property name="shortNullable" value="yes" />
<property name="nullPosition" value="last" />
</properties>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.UselessConstantTypeHint" />
<!-- <<< Functional -->

<!-- >>> Cleaning -->
<rule ref="SlevomatCodingStandard.Exceptions.DeadCatch" />
<rule ref="SlevomatCodingStandard.Functions.UnusedInheritedVariablePassedToClosure" />
<rule ref="SlevomatCodingStandard.Functions.UselessParameterDefaultValue" />
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses">
<properties>
<property name="searchAnnotations" value="true" />
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Namespaces.UseFromSameNamespace" />
<rule ref="SlevomatCodingStandard.Namespaces.UselessAlias" />
<rule ref="SlevomatCodingStandard.PHP.OptimizedFunctionsWithoutUnpacking" />
<rule ref="SlevomatCodingStandard.PHP.RequireNowdoc" />
<rule ref="SlevomatCodingStandard.PHP.UselessSemicolon" />
<rule ref="SlevomatCodingStandard.Variables.DisallowSuperGlobalVariable" />
<rule ref="SlevomatCodingStandard.Variables.DuplicateAssignmentToVariable" />
<rule ref="SlevomatCodingStandard.Variables.UnusedVariable" />
<rule ref="SlevomatCodingStandard.Variables.UselessVariable" />
<!-- <<< Cleaning -->

<!-- >>> Formatting -->
<rule ref="SlevomatCodingStandard.Arrays.MultiLineArrayEndBracketPlacement" />
<rule ref="SlevomatCodingStandard.Arrays.SingleLineArrayWhitespace">
<properties>
<property name="spacesAroundBrackets" value="0" />
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Arrays.TrailingArrayComma" />
<rule ref="SlevomatCodingStandard.Classes.ClassConstantVisibility" />
<rule ref="SlevomatCodingStandard.Classes.ClassMemberSpacing" />
<rule ref="SlevomatCodingStandard.Classes.MethodSpacing" />
<rule ref="SlevomatCodingStandard.Classes.ModernClassNameReference" />
<rule ref="SlevomatCodingStandard.Classes.PropertyDeclaration">
<properties>
<property name="modifiersOrder" type="array">
<element value="var" />
<element value="public, protected, private" />
<element value="static" />
<element value="static, readonly" />
</property>
<property name="checkPromoted" value="true" />
<property name="enableMultipleSpacesBetweenModifiersCheck" value="true" />
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Classes.RequireConstructorPropertyPromotion" />
<rule ref="SlevomatCodingStandard.Classes.UselessLateStaticBinding" />

<rule ref="SlevomatCodingStandard.Commenting.DocCommentSpacing">
<properties>
<property name="annotationsGroups" type="array">
Expand All @@ -157,7 +98,7 @@
<element value="@psalm-assert, @phan-assert" />
<element value="@property, @psalm-property" />
<element value="@see" />
<element value="@suppress, @psalm-suppress, @phpstan-ignore-line, @phpstan-ignore-next-line, @phan-file-suppress, @phan-suppress-next-line, @phan-suppress-current-line" />
<element value="@suppress, @psalm-suppress, @phpstan-ignore-line, @phpstan-ignore-next-line, @phan-file-suppress, @phan-suppress-next-line, @phan-suppress-current-line, @SuppressWarnings" />
</property>
</properties>
</rule>
Expand All @@ -171,40 +112,111 @@
</rule>
<rule ref="SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration" />
<rule ref="SlevomatCodingStandard.Commenting.UselessInheritDocComment" />

<rule ref="SlevomatCodingStandard.Complexity.Cognitive">
<properties>
<property name="maxComplexity" value="8" />
</properties>
</rule>

<rule ref="SlevomatCodingStandard.ControlStructures.AssignmentInCondition" />
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowContinueWithoutIntegerOperandInSwitch" />
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowTrailingMultiLineTernaryOperator" />
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowYodaComparison" />
<rule ref="SlevomatCodingStandard.ControlStructures.EarlyExit">
<properties>
<property name="ignoreStandaloneIfInScope" value="true" />
<property name="ignoreOneLineTrailingIf" value="true" />
<property name="ignoreTrailingIfWithOneInstruction" value="true" />
</properties>
</rule>
<rule ref="SlevomatCodingStandard.ControlStructures.NewWithParentheses" />
<rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceEqualOperator" />
<rule ref="SlevomatCodingStandard.ControlStructures.RequireNullSafeObjectOperator" />
<rule ref="SlevomatCodingStandard.ControlStructures.RequireShortTernaryOperator" />
<rule ref="SlevomatCodingStandard.ControlStructures.RequireTernaryOperator" />
<rule ref="SlevomatCodingStandard.ControlStructures.UselessIfConditionWithReturn" />
<rule ref="SlevomatCodingStandard.ControlStructures.UselessTernaryOperator" />
<rule ref="SlevomatCodingStandard.Functions.ArrowFunctionDeclaration" />

<rule ref="SlevomatCodingStandard.Exceptions.DeadCatch" />
<rule ref="SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly" />
<rule ref="SlevomatCodingStandard.Exceptions.RequireNonCapturingCatch" />

<rule ref="SlevomatCodingStandard.Functions.ArrowFunctionDeclaration">
<properties>
<property name="allowMultiLine" value="true" />
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Functions.StaticClosure" />
<rule ref="SlevomatCodingStandard.Functions.StrictCall" />
<rule ref="SlevomatCodingStandard.Functions.RequireArrowFunction" />
<rule ref="SlevomatCodingStandard.Functions.RequireTrailingCommaInCall" />
<rule ref="SlevomatCodingStandard.Functions.RequireTrailingCommaInDeclaration" />
<rule ref="SlevomatCodingStandard.Functions.UnusedInheritedVariablePassedToClosure" />
<rule ref="SlevomatCodingStandard.Functions.UselessParameterDefaultValue" />

<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses" />
<rule ref="SlevomatCodingStandard.Namespaces.DisallowGroupUse" />
<rule ref="SlevomatCodingStandard.Namespaces.NamespaceDeclaration" />
<rule ref="SlevomatCodingStandard.Namespaces.NamespaceSpacing" />
<rule ref="SlevomatCodingStandard.Namespaces.RequireOneNamespaceInFile" />
<rule ref="SlevomatCodingStandard.Namespaces.UseDoesNotStartWithBackslash" />
<rule ref="SlevomatCodingStandard.Namespaces.UseFromSameNamespace" />
<rule ref="SlevomatCodingStandard.Namespaces.UseSpacing">
<properties>
<property name="linesCountBetweenUseTypes" value="1" />
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Namespaces.UselessAlias" />
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses">
<properties>
<property name="searchAnnotations" value="true" />
</properties>
</rule>

<rule ref="SlevomatCodingStandard.Operators.DisallowEqualOperators" />

<rule ref="SlevomatCodingStandard.PHP.DisallowDirectMagicInvokeCall" />
<rule ref="SlevomatCodingStandard.PHP.OptimizedFunctionsWithoutUnpacking" />
<rule ref="SlevomatCodingStandard.PHP.RequireNowdoc" />
<rule ref="SlevomatCodingStandard.PHP.ShortList" />
<rule ref="SlevomatCodingStandard.PHP.TypeCast" />
<rule ref="SlevomatCodingStandard.PHP.UselessSemicolon" />

<rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes">
<properties>
<property name="linesCountBeforeDeclare" value="0" />
<property name="linesCountAfterDeclare" value="1" />
<property name="spacesCountAroundEqualsSign" value="0" />
</properties>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.DisallowArrayTypeHintSyntax">
<properties>
<property name="traversableTypeHints" value="true" />
</properties>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue" />
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing" />
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHintSpacing" />
<!-- <<< Formatting -->
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint">
<properties>
<property name="enableIntersectionTypeHint" value="false" />
</properties>
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification" />
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing" />
<rule ref="SlevomatCodingStandard.TypeHints.UnionTypeHintFormat">
<properties>
<property name="withSpaces" value="no" />
<property name="shortNullable" value="yes" />
<property name="nullPosition" value="last" />
</properties>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.UselessConstantTypeHint" />

<rule ref="SlevomatCodingStandard.Variables.DisallowSuperGlobalVariable" />
<rule ref="SlevomatCodingStandard.Variables.DuplicateAssignmentToVariable" />
<rule ref="SlevomatCodingStandard.Variables.UnusedVariable" />
<rule ref="SlevomatCodingStandard.Variables.UselessVariable" />
<!-- <<< Slevomat -->

</ruleset>
5 changes: 5 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@ parameters:
- vendor/bin/.phpunit/phpunit/vendor/autoload.php

checkMissingIterableValueType: false

ignoreErrors:
-
message: '/Cannot cast mixed to (int|float|string)/'
path: 'src/ArrayCastEnvVarProcessor.php'
2 changes: 2 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
strictBinaryOperands="true"
findUnusedPsalmSuppress="true"
sealAllMethods="true"
findUnusedBaselineEntry="false"
findUnusedCode="false"
xmlns="https://getpsalm.org/schema/config"
>
<projectFiles>
Expand Down
Loading

0 comments on commit a620805

Please sign in to comment.