diff --git a/config/set/php_codesniffer.php b/config/set/php_codesniffer.php index 2a4ae5b..45313e4 100644 --- a/config/set/php_codesniffer.php +++ b/config/set/php_codesniffer.php @@ -2,203 +2,158 @@ declare(strict_types=1); -namespace Symfony\Component\DependencyInjection\Loader\Configurator; - -use PHP_CodeSniffer\Standards\Generic\Sniffs\Arrays\ArrayIndentSniff; -use PHP_CodeSniffer\Standards\Generic\Sniffs\Arrays\DisallowLongArraySyntaxSniff; -use PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\EmptyPHPStatementSniff; -use PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\EmptyStatementSniff; -use PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\ForLoopShouldBeWhileLoopSniff; -use PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\ForLoopWithTestFunctionCallSniff; -use PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\JumbledIncrementerSniff; -use PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\UnconditionalIfStatementSniff; -use PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\UnnecessaryFinalModifierSniff; -use PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\UnusedFunctionParameterSniff; -use PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\UselessOverridingMethodSniff; -use PHP_CodeSniffer\Standards\Generic\Sniffs\Commenting\FixmeSniff; -use PHP_CodeSniffer\Standards\Generic\Sniffs\Commenting\TodoSniff; -use PHP_CodeSniffer\Standards\Generic\Sniffs\ControlStructures\InlineControlStructureSniff; -use PHP_CodeSniffer\Standards\Generic\Sniffs\Files\ByteOrderMarkSniff; -use PHP_CodeSniffer\Standards\Generic\Sniffs\Files\LineEndingsSniff; -use PHP_CodeSniffer\Standards\Generic\Sniffs\Files\LineLengthSniff; -use PHP_CodeSniffer\Standards\Generic\Sniffs\Files\OneClassPerFileSniff; -use PHP_CodeSniffer\Standards\Generic\Sniffs\Files\OneInterfacePerFileSniff; -use PHP_CodeSniffer\Standards\Generic\Sniffs\Files\OneTraitPerFileSniff; -use PHP_CodeSniffer\Standards\Generic\Sniffs\Formatting\DisallowMultipleStatementsSniff; -use PHP_CodeSniffer\Standards\Generic\Sniffs\Formatting\SpaceAfterCastSniff; -use PHP_CodeSniffer\Standards\Generic\Sniffs\Formatting\SpaceAfterNotSniff; -use PHP_CodeSniffer\Standards\Generic\Sniffs\Functions\CallTimePassByReferenceSniff; -use PHP_CodeSniffer\Standards\Generic\Sniffs\Functions\FunctionCallArgumentSpacingSniff; -use PHP_CodeSniffer\Standards\Generic\Sniffs\NamingConventions\UpperCaseConstantNameSniff; -use PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\BacktickOperatorSniff; -use PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\CharacterBeforePHPOpeningTagSniff; -use PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\DeprecatedFunctionsSniff; -use PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\DisallowAlternativePHPTagsSniff; -use PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\DisallowShortOpenTagSniff; -use PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\DiscourageGotoSniff; -use PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\ForbiddenFunctionsSniff; -use PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\LowerCaseConstantSniff; -use PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\LowerCaseKeywordSniff; -use PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\LowerCaseTypeSniff; -use PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\NoSilencedErrorsSniff; -use PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\SAPIUsageSniff; -use PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\SyntaxSniff; -use PHP_CodeSniffer\Standards\Generic\Sniffs\Strings\UnnecessaryStringConcatSniff; -use PHP_CodeSniffer\Standards\Generic\Sniffs\VersionControl\GitMergeConflictSniff; -use PHP_CodeSniffer\Standards\Generic\Sniffs\WhiteSpace\ArbitraryParenthesesSpacingSniff; -use PHP_CodeSniffer\Standards\Generic\Sniffs\WhiteSpace\DisallowTabIndentSniff; -use PHP_CodeSniffer\Standards\Generic\Sniffs\WhiteSpace\IncrementDecrementSpacingSniff; -use PHP_CodeSniffer\Standards\Generic\Sniffs\WhiteSpace\ScopeIndentSniff; -use PHP_CodeSniffer\Standards\PEAR\Sniffs\Functions\ValidDefaultValueSniff; -use PHP_CodeSniffer\Standards\PEAR\Sniffs\WhiteSpace\ObjectOperatorIndentSniff; -use PHP_CodeSniffer\Standards\PSR1\Sniffs\Files\SideEffectsSniff; -use PHP_CodeSniffer\Standards\PSR1\Sniffs\Methods\CamelCapsMethodNameSniff; -use PHP_CodeSniffer\Standards\PSR12\Sniffs\Classes\ClassInstantiationSniff; -use PHP_CodeSniffer\Standards\PSR12\Sniffs\Classes\ClosingBraceSniff; -use PHP_CodeSniffer\Standards\PSR12\Sniffs\ControlStructures\BooleanOperatorPlacementSniff; -use PHP_CodeSniffer\Standards\PSR12\Sniffs\ControlStructures\ControlStructureSpacingSniff; -use PHP_CodeSniffer\Standards\PSR12\Sniffs\Files\DeclareStatementSniff; -use PHP_CodeSniffer\Standards\PSR12\Sniffs\Files\ImportStatementSniff; -use PHP_CodeSniffer\Standards\PSR12\Sniffs\Files\OpenTagSniff; -use PHP_CodeSniffer\Standards\PSR12\Sniffs\Functions\NullableTypeDeclarationSniff; -use PHP_CodeSniffer\Standards\PSR12\Sniffs\Functions\ReturnTypeDeclarationSniff; -use PHP_CodeSniffer\Standards\PSR12\Sniffs\Keywords\ShortFormTypeKeywordsSniff; -use PHP_CodeSniffer\Standards\PSR12\Sniffs\Namespaces\CompoundNamespaceDepthSniff; -use PHP_CodeSniffer\Standards\PSR12\Sniffs\Operators\OperatorSpacingSniff; -use PHP_CodeSniffer\Standards\PSR12\Sniffs\Properties\ConstantVisibilitySniff; -use PHP_CodeSniffer\Standards\PSR2\Sniffs\Classes\ClassDeclarationSniff; -use PHP_CodeSniffer\Standards\PSR2\Sniffs\Classes\PropertyDeclarationSniff; -use PHP_CodeSniffer\Standards\PSR2\Sniffs\ControlStructures\ElseIfDeclarationSniff; -use PHP_CodeSniffer\Standards\PSR2\Sniffs\ControlStructures\SwitchDeclarationSniff; -use PHP_CodeSniffer\Standards\PSR2\Sniffs\Files\ClosingTagSniff; -use PHP_CodeSniffer\Standards\PSR2\Sniffs\Files\EndFileNewlineSniff; -use PHP_CodeSniffer\Standards\PSR2\Sniffs\Methods\FunctionCallSignatureSniff; -use PHP_CodeSniffer\Standards\PSR2\Sniffs\Methods\FunctionClosingBraceSniff; -use PHP_CodeSniffer\Standards\PSR2\Sniffs\Methods\MethodDeclarationSniff; -use PHP_CodeSniffer\Standards\Squiz\Sniffs\Arrays\ArrayBracketSpacingSniff; -use PHP_CodeSniffer\Standards\Squiz\Sniffs\Classes\ValidClassNameSniff; -use PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting\DocCommentAlignmentSniff; -use PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting\EmptyCatchCommentSniff; -use PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting\LongConditionClosingCommentSniff; -use PHP_CodeSniffer\Standards\Squiz\Sniffs\ControlStructures\ControlSignatureSniff; -use PHP_CodeSniffer\Standards\Squiz\Sniffs\ControlStructures\ForEachLoopDeclarationSniff; -use PHP_CodeSniffer\Standards\Squiz\Sniffs\ControlStructures\ForLoopDeclarationSniff; -use PHP_CodeSniffer\Standards\Squiz\Sniffs\ControlStructures\LowercaseDeclarationSniff; -use PHP_CodeSniffer\Standards\Squiz\Sniffs\Functions\FunctionDeclarationArgumentSpacingSniff; -use PHP_CodeSniffer\Standards\Squiz\Sniffs\Functions\FunctionDeclarationSniff; -use PHP_CodeSniffer\Standards\Squiz\Sniffs\Functions\LowercaseFunctionKeywordsSniff; -use PHP_CodeSniffer\Standards\Squiz\Sniffs\Functions\MultiLineFunctionDeclarationSniff; -use PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP\EvalSniff; -use PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP\GlobalKeywordSniff; -use PHP_CodeSniffer\Standards\Squiz\Sniffs\Scope\MethodScopeSniff; -use PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\CastSpacingSniff; -use PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\LanguageConstructSpacingSniff; -use PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\ScopeClosingBraceSniff; -use PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\ScopeKeywordSpacingSniff; -use PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\SuperfluousWhitespaceSniff; -use PHP_CodeSniffer\Standards\Zend\Sniffs\Debug\CodeAnalyzerSniff; +use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); - $services->set(ArrayIndentSniff::class); - $services->set(DisallowLongArraySyntaxSniff::class); - $services->set(EmptyPHPStatementSniff::class); - $services->set(EmptyStatementSniff::class); - $services->set(ForLoopShouldBeWhileLoopSniff::class); - $services->set(ForLoopWithTestFunctionCallSniff::class); - $services->set(JumbledIncrementerSniff::class); - $services->set(UnconditionalIfStatementSniff::class); - $services->set(UnnecessaryFinalModifierSniff::class); - $services->set(UnusedFunctionParameterSniff::class); - $services->set(UselessOverridingMethodSniff::class); - $services->set(FixmeSniff::class); - $services->set(TodoSniff::class); - $services->set(InlineControlStructureSniff::class) - ->property('error', 'true'); - $services->set(ByteOrderMarkSniff::class); - $services->set(LineEndingsSniff::class) - ->property('eolChar', '\n'); - $services->set(LineLengthSniff::class) - ->property('lineLimit', '120') - ->property('absoluteLineLimit', '0'); - $services->set(OneClassPerFileSniff::class); - $services->set(OneInterfacePerFileSniff::class); - $services->set(OneTraitPerFileSniff::class); - $services->set(DisallowMultipleStatementsSniff::class); - $services->set(SpaceAfterCastSniff::class); - $services->set(SpaceAfterNotSniff::class); - $services->set(CallTimePassByReferenceSniff::class); - $services->set(FunctionCallArgumentSpacingSniff::class); - $services->set(UpperCaseConstantNameSniff::class); - $services->set(BacktickOperatorSniff::class); - $services->set(CharacterBeforePHPOpeningTagSniff::class); - $services->set(DeprecatedFunctionsSniff::class); - $services->set(DisallowAlternativePHPTagsSniff::class); - $services->set(DisallowShortOpenTagSniff::class); - $services->set(DiscourageGotoSniff::class); - $services->set(ForbiddenFunctionsSniff::class); - $services->set(LowerCaseConstantSniff::class); - $services->set(LowerCaseKeywordSniff::class); - $services->set(LowerCaseTypeSniff::class); - $services->set(NoSilencedErrorsSniff::class); - $services->set(SAPIUsageSniff::class); - $services->set(SyntaxSniff::class); - $services->set(UnnecessaryStringConcatSniff::class); - $services->set(GitMergeConflictSniff::class); - $services->set(ArbitraryParenthesesSpacingSniff::class); - $services->set(DisallowTabIndentSniff::class); - $services->set(IncrementDecrementSpacingSniff::class); - $services->set(ScopeIndentSniff::class) + $services->set(\PHP_CodeSniffer\Standards\Generic\Sniffs\Metrics\NestingLevelSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Generic\Sniffs\Metrics\CyclomaticComplexitySniff::class); + $services->set(\PHP_CodeSniffer\Standards\Generic\Sniffs\Strings\UnnecessaryStringConcatSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Generic\Sniffs\Classes\DuplicateClassNameSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\UnusedFunctionParameterSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\UselessOverridingMethodSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\UnnecessaryFinalModifierSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\ForLoopShouldBeWhileLoopSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\JumbledIncrementerSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\AssignmentInConditionSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\EmptyPHPStatementSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\UnconditionalIfStatementSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\ForLoopWithTestFunctionCallSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\EmptyStatementSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\ForbiddenFunctionsSniff::class) + ->property('forbiddenFunctions', [ + 'sizeof' => 'count', + 'delete' => 'unset', + 'print' => 'echo', + 'is_null' => 'null', + 'create_function' => 'null', + ]); + $services->set(\PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\CharacterBeforePHPOpeningTagSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\SyntaxSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\LowerCaseTypeSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\DisallowShortOpenTagSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\DisallowRequestSuperglobalSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\LowerCaseConstantSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\DiscourageGotoSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\DisallowAlternativePHPTagsSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\SAPIUsageSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\BacktickOperatorSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\LowerCaseKeywordSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\NoSilencedErrorsSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\DeprecatedFunctionsSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Generic\Sniffs\VersionControl\SubversionPropertiesSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Generic\Sniffs\VersionControl\GitMergeConflictSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Generic\Sniffs\WhiteSpace\ScopeIndentSniff::class) ->property('ignoreIndentationTokens', ['T_COMMENT', 'T_DOC_COMMENT_OPEN_TAG']); - $services->set(ValidDefaultValueSniff::class); - $services->set(ObjectOperatorIndentSniff::class); - $services->set(ClassInstantiationSniff::class); - $services->set(ClosingBraceSniff::class); - $services->set(BooleanOperatorPlacementSniff::class); - $services->set(ControlStructureSpacingSniff::class); - $services->set(DeclareStatementSniff::class); - $services->set(ImportStatementSniff::class); - $services->set(OpenTagSniff::class); - $services->set(NullableTypeDeclarationSniff::class); - $services->set(ReturnTypeDeclarationSniff::class); - $services->set(ShortFormTypeKeywordsSniff::class); - $services->set(CompoundNamespaceDepthSniff::class); - $services->set(OperatorSpacingSniff::class); - $services->set(ConstantVisibilitySniff::class); - $services->set(SideEffectsSniff::class); - $services->set(CamelCapsMethodNameSniff::class); - $services->set(ClassDeclarationSniff::class); - $services->set(PropertyDeclarationSniff::class); - $services->set(ElseIfDeclarationSniff::class); - $services->set(SwitchDeclarationSniff::class); - $services->set(ClosingTagSniff::class); - $services->set(EndFileNewlineSniff::class); - $services->set(FunctionCallSignatureSniff::class); - $services->set(FunctionClosingBraceSniff::class); - $services->set(MethodDeclarationSniff::class); - $services->set(ArrayBracketSpacingSniff::class); - $services->set(ValidClassNameSniff::class); - $services->set(DocCommentAlignmentSniff::class); - $services->set(EmptyCatchCommentSniff::class); - $services->set(LongConditionClosingCommentSniff::class); - $services->set(ControlSignatureSniff::class); - $services->set(ForEachLoopDeclarationSniff::class); - $services->set(ForLoopDeclarationSniff::class) - ->property('ignoreNewlines', 'true'); - $services->set(LowercaseDeclarationSniff::class); - $services->set(FunctionDeclarationArgumentSpacingSniff::class) - ->property('equalsSpacing', '1'); - $services->set(FunctionDeclarationSniff::class); - $services->set(LowercaseFunctionKeywordsSniff::class); - $services->set(MultiLineFunctionDeclarationSniff::class); - $services->set(EvalSniff::class); - $services->set(GlobalKeywordSniff::class); - $services->set(MethodScopeSniff::class); - $services->set(CastSpacingSniff::class); - $services->set(LanguageConstructSpacingSniff::class); - $services->set(ScopeClosingBraceSniff::class); - $services->set(ScopeKeywordSpacingSniff::class); - $services->set(SuperfluousWhitespaceSniff::class) + $services->set(\PHP_CodeSniffer\Standards\Generic\Sniffs\WhiteSpace\ArbitraryParenthesesSpacingSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Generic\Sniffs\WhiteSpace\DisallowTabIndentSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Generic\Sniffs\WhiteSpace\IncrementDecrementSpacingSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Generic\Sniffs\WhiteSpace\SpreadOperatorSpacingAfterSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Generic\Sniffs\Formatting\DisallowMultipleStatementsSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Generic\Sniffs\Formatting\SpaceAfterNotSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Generic\Sniffs\Formatting\SpaceAfterCastSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Generic\Sniffs\Arrays\ArrayIndentSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Generic\Sniffs\Arrays\DisallowLongArraySyntaxSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Generic\Sniffs\Files\LineLengthSniff::class) + ->property('lineLimit', '120') + ->property('absoluteLineLimit', '0') + ->property('ignoreComments', 'true'); + $services->set(\PHP_CodeSniffer\Standards\Generic\Sniffs\Files\ByteOrderMarkSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Generic\Sniffs\Files\OneObjectStructurePerFileSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Generic\Sniffs\Files\LineEndingsSniff::class) + ->property('eolChar', '\\n'); + $services->set(\PHP_CodeSniffer\Standards\Generic\Sniffs\Files\OneTraitPerFileSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Generic\Sniffs\Files\OneInterfacePerFileSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Generic\Sniffs\Files\OneClassPerFileSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Generic\Sniffs\Files\ExecutableFileSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Generic\Sniffs\Files\EndFileNewlineSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Generic\Sniffs\Functions\FunctionCallArgumentSpacingSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Generic\Sniffs\Functions\CallTimePassByReferenceSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Generic\Sniffs\ControlStructures\InlineControlStructureSniff::class) + ->property('error', 'true'); + $services->set(\PHP_CodeSniffer\Standards\Generic\Sniffs\ControlStructures\DisallowYodaConditionsSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Generic\Sniffs\NamingConventions\UpperCaseConstantNameSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Generic\Sniffs\Commenting\TodoSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Generic\Sniffs\Commenting\FixmeSniff::class); + $services->set(\PHP_CodeSniffer\Standards\PEAR\Sniffs\Classes\ClassDeclarationSniff::class); + $services->set(\PHP_CodeSniffer\Standards\PEAR\Sniffs\WhiteSpace\ObjectOperatorIndentSniff::class); + $services->set(\PHP_CodeSniffer\Standards\PEAR\Sniffs\WhiteSpace\ScopeClosingBraceSniff::class); + $services->set(\PHP_CodeSniffer\Standards\PEAR\Sniffs\Functions\FunctionDeclarationSniff::class); + $services->set(\PHP_CodeSniffer\Standards\PEAR\Sniffs\Functions\ValidDefaultValueSniff::class); + $services->set(\PHP_CodeSniffer\Standards\PEAR\Sniffs\NamingConventions\ValidClassNameSniff::class); + $services->set(\PHP_CodeSniffer\Standards\PEAR\Sniffs\Commenting\InlineCommentSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting\DocCommentAlignmentSniff::class); + $services->set(\PHP_CodeSniffer\Standards\PSR1\Sniffs\Methods\CamelCapsMethodNameSniff::class); + $services->set(\PHP_CodeSniffer\Standards\PSR1\Sniffs\Classes\ClassDeclarationSniff::class); + $services->set(\PHP_CodeSniffer\Standards\PSR1\Sniffs\Files\SideEffectsSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Squiz\Sniffs\Classes\ValidClassNameSniff::class); + $services->set(\PHP_CodeSniffer\Standards\PSR2\Sniffs\Methods\FunctionCallSignatureSniff::class); + $services->set(\PHP_CodeSniffer\Standards\PSR2\Sniffs\Methods\MethodDeclarationSniff::class); + $services->set(\PHP_CodeSniffer\Standards\PSR2\Sniffs\Methods\FunctionClosingBraceSniff::class); + $services->set(\PHP_CodeSniffer\Standards\PSR2\Sniffs\Classes\PropertyDeclarationSniff::class); + $services->set(\PHP_CodeSniffer\Standards\PSR2\Sniffs\Classes\ClassDeclarationSniff::class); + $services->set(\PHP_CodeSniffer\Standards\PSR2\Sniffs\Namespaces\UseDeclarationSniff::class); + $services->set(\PHP_CodeSniffer\Standards\PSR2\Sniffs\Namespaces\NamespaceDeclarationSniff::class); + $services->set(\PHP_CodeSniffer\Standards\PSR2\Sniffs\Files\ClosingTagSniff::class); + $services->set(\PHP_CodeSniffer\Standards\PSR2\Sniffs\Files\EndFileNewlineSniff::class); + $services->set(\PHP_CodeSniffer\Standards\PSR2\Sniffs\ControlStructures\SwitchDeclarationSniff::class); + $services->set(\PHP_CodeSniffer\Standards\PSR2\Sniffs\ControlStructures\ElseIfDeclarationSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\SuperfluousWhitespaceSniff::class) ->property('ignoreBlankLines', 'true'); - $services->set(CodeAnalyzerSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Squiz\Sniffs\Scope\MethodScopeSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\ScopeKeywordSpacingSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Squiz\Sniffs\Functions\FunctionDeclarationSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Squiz\Sniffs\Functions\LowercaseFunctionKeywordsSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Squiz\Sniffs\Functions\FunctionDeclarationArgumentSpacingSniff::class) + ->property('equalsSpacing', '1'); + $services->set(\PHP_CodeSniffer\Standards\Squiz\Sniffs\Functions\MultiLineFunctionDeclarationSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Squiz\Sniffs\ControlStructures\ControlSignatureSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\ScopeClosingBraceSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Squiz\Sniffs\ControlStructures\ForEachLoopDeclarationSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Squiz\Sniffs\ControlStructures\ForLoopDeclarationSniff::class) + ->property('ignoreNewlines', 'true'); + $services->set(\PHP_CodeSniffer\Standards\Squiz\Sniffs\ControlStructures\LowercaseDeclarationSniff::class); + $services->set(\PHP_CodeSniffer\Standards\PSR12\Sniffs\Classes\OpeningBraceSpaceSniff::class); + $services->set(\PHP_CodeSniffer\Standards\PSR12\Sniffs\Classes\ClosingBraceSniff::class); + $services->set(\PHP_CodeSniffer\Standards\PSR12\Sniffs\Classes\ClassInstantiationSniff::class); + $services->set(\PHP_CodeSniffer\Standards\PSR12\Sniffs\Namespaces\CompoundNamespaceDepthSniff::class); + $services->set(\PHP_CodeSniffer\Standards\PSR12\Sniffs\Properties\ConstantVisibilitySniff::class); + $services->set(\PHP_CodeSniffer\Standards\PSR12\Sniffs\Files\ImportStatementSniff::class); + $services->set(\PHP_CodeSniffer\Standards\PSR12\Sniffs\Files\OpenTagSniff::class); + $services->set(\PHP_CodeSniffer\Standards\PSR12\Sniffs\Files\DeclareStatementSniff::class); + $services->set(\PHP_CodeSniffer\Standards\PSR12\Sniffs\Functions\NullableTypeDeclarationSniff::class); + $services->set(\PHP_CodeSniffer\Standards\PSR12\Sniffs\Functions\ReturnTypeDeclarationSniff::class); + $services->set(\PHP_CodeSniffer\Standards\PSR12\Sniffs\ControlStructures\ControlStructureSpacingSniff::class); + $services->set(\PHP_CodeSniffer\Standards\PSR12\Sniffs\ControlStructures\BooleanOperatorPlacementSniff::class); + $services->set(\PHP_CodeSniffer\Standards\PSR12\Sniffs\Keywords\ShortFormTypeKeywordsSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\CastSpacingSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Squiz\Sniffs\Strings\EchoedStringsSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Squiz\Sniffs\Operators\IncrementDecrementUsageSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Squiz\Sniffs\Operators\ValidLogicalOperatorsSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Squiz\Sniffs\Classes\LowercaseClassKeywordsSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Squiz\Sniffs\Classes\SelfMemberReferenceSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Squiz\Sniffs\Classes\ClassFileNameSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Squiz\Sniffs\Classes\ClassDeclarationSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Squiz\Sniffs\Scope\MemberVarScopeSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Squiz\Sniffs\Scope\StaticThisUsageSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP\InnerFunctionsSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP\EvalSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP\GlobalKeywordSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP\DiscouragedFunctionsSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP\CommentedOutCodeSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP\LowercasePHPFunctionsSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP\DisallowSizeFunctionsInLoopsSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP\EmbeddedPhpSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP\NonExecutableCodeSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\LogicalOperatorSpacingSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\LanguageConstructSpacingSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\FunctionOpeningBraceSpaceSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\SemicolonSpacingSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Squiz\Sniffs\Arrays\ArrayBracketSpacingSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Squiz\Sniffs\Functions\GlobalFunctionSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Squiz\Sniffs\Functions\FunctionDuplicateArgumentSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting\LongConditionClosingCommentSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting\EmptyCatchCommentSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Zend\Sniffs\Files\ClosingTagSniff::class); + $services->set(\PHP_CodeSniffer\Standards\Zend\Sniffs\Debug\CodeAnalyzerSniff::class); }; diff --git a/config/set/slevomat-coding-standard.php b/config/set/slevomat-coding-standard.php index 5fb7b36..d183a7b 100644 --- a/config/set/slevomat-coding-standard.php +++ b/config/set/slevomat-coding-standard.php @@ -2,136 +2,109 @@ declare(strict_types=1); -namespace Symfony\Component\DependencyInjection\Loader\Configurator; - -use PHP_CodeSniffer\Config; -use SlevomatCodingStandard\Sniffs\Arrays\DisallowImplicitArrayCreationSniff; -use SlevomatCodingStandard\Sniffs\Arrays\TrailingArrayCommaSniff; -use SlevomatCodingStandard\Sniffs\Classes\ClassConstantVisibilitySniff; -use SlevomatCodingStandard\Sniffs\Classes\DisallowLateStaticBindingForConstantsSniff; -use SlevomatCodingStandard\Sniffs\Classes\DisallowMultiConstantDefinitionSniff; -use SlevomatCodingStandard\Sniffs\Classes\DisallowMultiPropertyDefinitionSniff; -use SlevomatCodingStandard\Sniffs\Classes\ModernClassNameReferenceSniff; -use SlevomatCodingStandard\Sniffs\Classes\ParentCallSpacingSniff; -use SlevomatCodingStandard\Sniffs\Classes\SuperfluousAbstractClassNamingSniff; -use SlevomatCodingStandard\Sniffs\Classes\SuperfluousInterfaceNamingSniff; -use SlevomatCodingStandard\Sniffs\Classes\SuperfluousTraitNamingSniff; -use SlevomatCodingStandard\Sniffs\Classes\TraitUseDeclarationSniff; -use SlevomatCodingStandard\Sniffs\Classes\TraitUseSpacingSniff; -use SlevomatCodingStandard\Sniffs\Classes\UselessLateStaticBindingSniff; -use SlevomatCodingStandard\Sniffs\Commenting\DisallowCommentAfterCodeSniff; -use SlevomatCodingStandard\Sniffs\Commenting\EmptyCommentSniff; -use SlevomatCodingStandard\Sniffs\Commenting\ForbiddenCommentsSniff; -use SlevomatCodingStandard\Sniffs\Commenting\InlineDocCommentDeclarationSniff; -use SlevomatCodingStandard\Sniffs\Commenting\UselessFunctionDocCommentSniff; -use SlevomatCodingStandard\Sniffs\Commenting\UselessInheritDocCommentSniff; -use SlevomatCodingStandard\Sniffs\ControlStructures\AssignmentInConditionSniff; -use SlevomatCodingStandard\Sniffs\ControlStructures\DisallowContinueWithoutIntegerOperandInSwitchSniff; -use SlevomatCodingStandard\Sniffs\ControlStructures\DisallowYodaComparisonSniff; -use SlevomatCodingStandard\Sniffs\ControlStructures\LanguageConstructWithParenthesesSniff; -use SlevomatCodingStandard\Sniffs\ControlStructures\RequireShortTernaryOperatorSniff; -use SlevomatCodingStandard\Sniffs\Exceptions\DeadCatchSniff; -use SlevomatCodingStandard\Sniffs\Exceptions\ReferenceThrowableOnlySniff; -use SlevomatCodingStandard\Sniffs\Functions\UnusedInheritedVariablePassedToClosureSniff; -use SlevomatCodingStandard\Sniffs\Functions\UselessParameterDefaultValueSniff; -use SlevomatCodingStandard\Sniffs\Namespaces\FullyQualifiedClassNameInAnnotationSniff; -use SlevomatCodingStandard\Sniffs\Namespaces\NamespaceDeclarationSniff; -use SlevomatCodingStandard\Sniffs\Namespaces\NamespaceSpacingSniff; -use SlevomatCodingStandard\Sniffs\Namespaces\RequireOneNamespaceInFileSniff; -use SlevomatCodingStandard\Sniffs\Namespaces\UnusedUsesSniff; -use SlevomatCodingStandard\Sniffs\Namespaces\UseDoesNotStartWithBackslashSniff; -use SlevomatCodingStandard\Sniffs\Namespaces\UseFromSameNamespaceSniff; -use SlevomatCodingStandard\Sniffs\Namespaces\UselessAliasSniff; -use SlevomatCodingStandard\Sniffs\Namespaces\UseSpacingSniff; -use SlevomatCodingStandard\Sniffs\Operators\RequireCombinedAssignmentOperatorSniff; -use SlevomatCodingStandard\Sniffs\Operators\RequireOnlyStandaloneIncrementAndDecrementOperatorsSniff; -use SlevomatCodingStandard\Sniffs\Operators\SpreadOperatorSpacingSniff; -use SlevomatCodingStandard\Sniffs\PHP\DisallowDirectMagicInvokeCallSniff; -use SlevomatCodingStandard\Sniffs\PHP\OptimizedFunctionsWithoutUnpackingSniff; -use SlevomatCodingStandard\Sniffs\PHP\ShortListSniff; -use SlevomatCodingStandard\Sniffs\PHP\TypeCastSniff; -use SlevomatCodingStandard\Sniffs\PHP\UselessParenthesesSniff; -use SlevomatCodingStandard\Sniffs\PHP\UselessSemicolonSniff; -use SlevomatCodingStandard\Sniffs\TypeHints\LongTypeHintsSniff; -use SlevomatCodingStandard\Sniffs\TypeHints\NullableTypeForNullDefaultValueSniff; -use SlevomatCodingStandard\Sniffs\TypeHints\NullTypeHintOnLastPositionSniff; -use SlevomatCodingStandard\Sniffs\TypeHints\ParameterTypeHintSpacingSniff; -use SlevomatCodingStandard\Sniffs\TypeHints\PropertyTypeHintSniff; -use SlevomatCodingStandard\Sniffs\TypeHints\ReturnTypeHintSniff; -use SlevomatCodingStandard\Sniffs\TypeHints\ReturnTypeHintSpacingSniff; -use SlevomatCodingStandard\Sniffs\Variables\DuplicateAssignmentToVariableSniff; -use SlevomatCodingStandard\Sniffs\Variables\UnusedVariableSniff; -use SlevomatCodingStandard\Sniffs\Variables\UselessVariableSniff; -use SlevomatCodingStandard\Sniffs\Whitespaces\DuplicateSpacesSniff; +use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; return static function (ContainerConfigurator $containerConfigurator): void { - Config::setConfigData('php_version', 70200); $services = $containerConfigurator->services(); - $services->set(DisallowImplicitArrayCreationSniff::class); - $services->set(TrailingArrayCommaSniff::class); - $services->set(ClassConstantVisibilitySniff::class); - $services->set(DisallowLateStaticBindingForConstantsSniff::class); - $services->set(DisallowMultiConstantDefinitionSniff::class); - $services->set(DisallowMultiPropertyDefinitionSniff::class); - $services->set(ModernClassNameReferenceSniff::class); - $services->set(ParentCallSpacingSniff::class); - $services->set(SuperfluousAbstractClassNamingSniff::class); - $services->set(SuperfluousInterfaceNamingSniff::class); - $services->set(SuperfluousTraitNamingSniff::class); - $services->set(TraitUseDeclarationSniff::class); - $services->set(TraitUseSpacingSniff::class) - ->property('linesCountAfterLastUse', 1) - ->property('linesCountAfterLastUseWhenLastInClass', 0) - ->property('linesCountBeforeFirstUse', 0); - $services->set(UselessLateStaticBindingSniff::class); - $services->set(EmptyCommentSniff::class); - $services->set(ForbiddenCommentsSniff::class); - $services->set(UselessInheritDocCommentSniff::class); - $services->set(AssignmentInConditionSniff::class); - $services->set(DisallowContinueWithoutIntegerOperandInSwitchSniff::class); - $services->set(DisallowYodaComparisonSniff::class); - $services->set(LanguageConstructWithParenthesesSniff::class); - $services->set(RequireShortTernaryOperatorSniff::class); - $services->set(DeadCatchSniff::class); - $services->set(ReferenceThrowableOnlySniff::class); - $services->set(UnusedInheritedVariablePassedToClosureSniff::class); - $services->set(UselessParameterDefaultValueSniff::class); - $services->set(FullyQualifiedClassNameInAnnotationSniff::class); - $services->set(NamespaceDeclarationSniff::class); - $services->set(NamespaceSpacingSniff::class); - $services->set(RequireOneNamespaceInFileSniff::class); - $services->set(UseDoesNotStartWithBackslashSniff::class); - $services->set(UseFromSameNamespaceSniff::class); - $services->set(UseSpacingSniff::class); - $services->set(UselessAliasSniff::class); - $services->set(RequireCombinedAssignmentOperatorSniff::class); - $services->set(RequireOnlyStandaloneIncrementAndDecrementOperatorsSniff::class); - $services->set(SpreadOperatorSpacingSniff::class); - $services->set(DisallowDirectMagicInvokeCallSniff::class); - $services->set(OptimizedFunctionsWithoutUnpackingSniff::class); - $services->set(ShortListSniff::class); - $services->set(TypeCastSniff::class); - $services->set(UselessParenthesesSniff::class); - $services->set(UselessSemicolonSniff::class); - $services->set(LongTypeHintsSniff::class); - $services->set(NullTypeHintOnLastPositionSniff::class); - $services->set(NullableTypeForNullDefaultValueSniff::class); - $services->set(ParameterTypeHintSpacingSniff::class); - $services->set(ReturnTypeHintSpacingSniff::class); - $services->set(DuplicateAssignmentToVariableSniff::class); - $services->set(UnusedVariableSniff::class); - $services->set(UselessVariableSniff::class); - $services->set(DuplicateSpacesSniff::class); - // Conflict with declaration must be compatible with parent method -// $services->set(\SlevomatCodingStandard\Sniffs\TypeHints\ParameterTypeHintSniff::class); -// $services->set(\SlevomatCodingStandard\Sniffs\TypeHints\ParameterTypeHintSniff::class); - $services->set(PropertyTypeHintSniff::class); - $services->set(ReturnTypeHintSniff::class); - $services->set(UnusedUsesSniff::class) - ->property('searchAnnotations', true); - // Conflict with VarConstantCommentRector -// $services->set(\SlevomatCodingStandard\Sniffs\TypeHints\UselessConstantTypeHintSniff::class); - $services->set(InlineDocCommentDeclarationSniff::class); - $services->set(UselessFunctionDocCommentSniff::class); - $services->set(DisallowCommentAfterCodeSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\Numbers\DisallowNumericLiteralSeparatorSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\Operators\NegationOperatorSpacingSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\Operators\SpreadOperatorSpacingSniff::class); + $services->set( + \SlevomatCodingStandard\Sniffs\Operators\RequireOnlyStandaloneIncrementAndDecrementOperatorsSniff::class + ); + $services->set(\SlevomatCodingStandard\Sniffs\Operators\RequireCombinedAssignmentOperatorSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\Classes\ClassMemberSpacingSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\Classes\RequireMultiLineMethodSignatureSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\Classes\ConstantSpacingSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\Classes\TraitUseSpacingSniff::class) + ->property('linesCountAfterLastUse', '1') + ->property('linesCountAfterLastUseWhenLastInClass', '0') + ->property('linesCountBeforeFirstUse', '0'); + $services->set(\SlevomatCodingStandard\Sniffs\Classes\ParentCallSpacingSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\Classes\SuperfluousInterfaceNamingSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\Classes\SuperfluousTraitNamingSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\Classes\SuperfluousAbstractClassNamingSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\Classes\DisallowMultiConstantDefinitionSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\Classes\ModernClassNameReferenceSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\Classes\UselessLateStaticBindingSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\Classes\DisallowMultiPropertyDefinitionSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\Classes\PropertySpacingSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\Classes\ClassConstantVisibilitySniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\Classes\MethodSpacingSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\Classes\DisallowLateStaticBindingForConstantsSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\Classes\TraitUseDeclarationSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\Whitespaces\DuplicateSpacesSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\PHP\DisallowDirectMagicInvokeCallSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\PHP\RequireNowdocSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\PHP\TypeCastSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\PHP\ForbiddenClassesSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\PHP\ShortListSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\PHP\ReferenceSpacingSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\PHP\OptimizedFunctionsWithoutUnpackingSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\PHP\UselessParenthesesSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\PHP\UselessSemicolonSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\Exceptions\DeadCatchSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\Exceptions\RequireNonCapturingCatchSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\Exceptions\ReferenceThrowableOnlySniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\Namespaces\UselessAliasSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\Namespaces\FullyQualifiedClassNameInAnnotationSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\Namespaces\UseDoesNotStartWithBackslashSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\Namespaces\AlphabeticallySortedUsesSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\Namespaces\MultipleUsesPerLineSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\Namespaces\UnusedUsesSniff::class) + ->property('searchAnnotations', 'true'); + $services->set(\SlevomatCodingStandard\Sniffs\Namespaces\DisallowGroupUseSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\Namespaces\UseSpacingSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\Namespaces\NamespaceSpacingSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\Namespaces\NamespaceDeclarationSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\Namespaces\RequireOneNamespaceInFileSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\Namespaces\UseFromSameNamespaceSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\Variables\UselessVariableSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\Variables\DisallowSuperGlobalVariableSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\Variables\UnusedVariableSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\Variables\DuplicateAssignmentToVariableSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\Arrays\MultiLineArrayEndBracketPlacementSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\Arrays\DisallowImplicitArrayCreationSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\Arrays\TrailingArrayCommaSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\Functions\DisallowNamedArgumentsSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\Functions\RequireArrowFunctionSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\Functions\UnusedInheritedVariablePassedToClosureSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\Functions\UselessParameterDefaultValueSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\Functions\ArrowFunctionDeclarationSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\ControlStructures\RequireNullCoalesceOperatorSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\ControlStructures\RequireShortTernaryOperatorSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\ControlStructures\RequireNullCoalesceEqualOperatorSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\ControlStructures\NewWithParenthesesSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\ControlStructures\UselessTernaryOperatorSniff::class); + $services->set( + \SlevomatCodingStandard\Sniffs\ControlStructures\DisallowContinueWithoutIntegerOperandInSwitchSniff::class + ); + $services->set(\SlevomatCodingStandard\Sniffs\ControlStructures\AssignmentInConditionSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\ControlStructures\RequireNullSafeObjectOperatorSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\ControlStructures\DisallowNullSafeObjectOperatorSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\ControlStructures\LanguageConstructWithParenthesesSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\ControlStructures\UselessIfConditionWithReturnSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\ControlStructures\DisallowYodaComparisonSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\TypeHints\ParameterTypeHintSpacingSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\TypeHints\LongTypeHintsSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\TypeHints\NullTypeHintOnLastPositionSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\TypeHints\PropertyTypeHintSpacingSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\TypeHints\UnionTypeHintFormatSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\TypeHints\PropertyTypeHintSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\TypeHints\DeclareStrictTypesSniff::class) + ->property('newlinesCountBetweenOpenTagAndDeclare', '2') + ->property('spacesCountAroundEqualsSign', '0'); + $services->set(\SlevomatCodingStandard\Sniffs\TypeHints\ReturnTypeHintSpacingSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\TypeHints\NullableTypeForNullDefaultValueSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\TypeHints\ReturnTypeHintSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\Commenting\UselessInheritDocCommentSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\Commenting\ForbiddenAnnotationsSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\Commenting\InlineDocCommentDeclarationSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\Commenting\UselessFunctionDocCommentSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\Commenting\DocCommentSpacingSniff::class) + ->property('linesCountBetweenDifferentAnnotationsTypes', '1'); + $services->set(\SlevomatCodingStandard\Sniffs\Commenting\DisallowCommentAfterCodeSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\Commenting\ForbiddenCommentsSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\Commenting\EmptyCommentSniff::class); + $services->set(\SlevomatCodingStandard\Sniffs\Commenting\DisallowOneLinePropertyDocCommentSniff::class); }; diff --git a/ecs.php b/ecs.php index 410eea1..d579569 100644 --- a/ecs.php +++ b/ecs.php @@ -8,6 +8,7 @@ use Zing\CodingStandard\Set\ECSSetList; return static function (ContainerConfigurator $containerConfigurator): void { + \PHP_CodeSniffer\Config::setConfigData('php_version', 70200); $containerConfigurator->import(ECSSetList::PHP71_MIGRATION); $containerConfigurator->import(ECSSetList::PHP71_MIGRATION_RISKY); $containerConfigurator->import(ECSSetList::CUSTOM); diff --git a/src/PHPCodeSnifferRuleSetGenerator.php b/src/PHPCodeSnifferRuleSetGenerator.php index 3af3e3c..e3d8498 100644 --- a/src/PHPCodeSnifferRuleSetGenerator.php +++ b/src/PHPCodeSnifferRuleSetGenerator.php @@ -25,6 +25,8 @@ final class PHPCodeSnifferRuleSetGenerator 'Squiz' => 'squiz.php', 'Zend' => 'zend.php', 'SlevomatCodingStandard' => 'slevomat-coding-standard.php', + 'PHPCodeSnifferCustom' => '../php_codesniffer.php', + 'SlevomatCodingStandardCustom' => '../slevomat-coding-standard.php', ]; /** @@ -62,12 +64,19 @@ private function formatRulesToServices(Ruleset $ruleset): array { $sniffs = []; foreach ($ruleset->sniffs as $sniff) { + if (! $this->isPhpSniff($sniff, str_contains($ruleset->name, 'Custom'))) { + continue; + } + $sniffs[is_object($sniff) ? get_class($sniff) : $sniff] = []; } foreach ($ruleset->ruleset as $code => $attr) { if (isset($ruleset->sniffCodes[$code])) { $sniff = $ruleset->sniffCodes[$code]; + if (! $this->isPhpSniff($sniff, str_contains($ruleset->name, 'Custom'))) { + continue; + } $sniffs[$sniff] = $attr['properties'] ?? []; } @@ -76,6 +85,24 @@ private function formatRulesToServices(Ruleset $ruleset): array return $sniffs; } + private function isPhpSniff($sniff, bool $isStandard = false): bool + { + if (! $isStandard) { + return true; + } + + if (! class_exists($sniff)) { + return false; + } + + $sniffObject = new $sniff(); + if (! property_exists($sniffObject, 'supportedTokenizers')) { + return true; + } + + return in_array('PHP', $sniffObject->supportedTokenizers, true); + } + /** * @return iterable<\Symfony\Component\Finder\SplFileInfo> */ @@ -90,5 +117,9 @@ private function getSetDefinitions(): iterable ->files() ->in(__DIR__ . '/../vendor/slevomat/coding-standard') ->name('ruleset.xml'); + yield from Finder::create() + ->files() + ->in(__DIR__ . '/Standards') + ->name('ruleset.xml'); } } diff --git a/src/Printer.php b/src/Printer.php index 97aba6d..4e93157 100644 --- a/src/Printer.php +++ b/src/Printer.php @@ -48,15 +48,17 @@ protected function hasNodeWithComments(array $nodes): bool protected function pExpr_MethodCall(MethodCall $node): string { - $nextCallIndentReplacement = ')' . PHP_EOL . preg_replace( - '#(?:^|[\\r\\n]+)(?=[^\\r\\n])#', - '$0' . \str_repeat(' ', 8), - '->' - ); - $content = parent::pExpr_MethodCall($node); - $content = preg_replace('#\\n#', PHP_EOL . str_repeat(' ', 4), $content); + if ($node->var instanceof MethodCall) { + $var = $this->pDereferenceLhs($node->var); + $this->indent(); + $content = $var . $this->nl . '->' . $this->pObjectProperty($node->name) + . '(' . $this->pMaybeMultiline($node->args) . ')'; + $this->outdent(); - return preg_replace('#\)->#', $nextCallIndentReplacement, $content); + return $content; + } + + return parent::pExpr_MethodCall($node); } protected function pExpr_Closure(Closure $node): string diff --git a/src/Standards/PHPCodeSnifferCustom/ruleset.xml b/src/Standards/PHPCodeSnifferCustom/ruleset.xml new file mode 100644 index 0000000..bd3448b --- /dev/null +++ b/src/Standards/PHPCodeSnifferCustom/ruleset.xml @@ -0,0 +1,174 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */migrations/* + */seeds/* + + + *Test.php + + + + + + + + + + + + + + + + + diff --git a/src/Standards/SlevomatCodingStandardCustom/ruleset.xml b/src/Standards/SlevomatCodingStandardCustom/ruleset.xml new file mode 100644 index 0000000..339fb8a --- /dev/null +++ b/src/Standards/SlevomatCodingStandardCustom/ruleset.xml @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +