From 0faf2879df22622feae49deadb0aef7548ad522d Mon Sep 17 00:00:00 2001 From: Joshua Ramon Enslin Date: Thu, 3 Sep 2020 15:51:16 +0200 Subject: [PATCH] Initial --- README.org | 11 ++++ rules/phpstan-rules.neon | 123 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 134 insertions(+) create mode 100644 README.org create mode 100644 rules/phpstan-rules.neon diff --git a/README.org b/README.org new file mode 100644 index 0000000..3f20cf0 --- /dev/null +++ b/README.org @@ -0,0 +1,11 @@ +* Quality Assurance Settings for museum-digital + +** Tools used + +- [[https://github.com/squizlabs/PHP_CodeSniffer][php-codesniffer]] +- [[https://github.com/phpstan/phpstan][PHPStan - PHP Static Analysis Tool]] +- [[https://phpunit.de/][phpunit]] + +** This Repository + +This repository serves to collect generally applicable rules, that can be embedded into the specific rule sets of the different projects. diff --git a/rules/phpstan-rules.neon b/rules/phpstan-rules.neon new file mode 100644 index 0000000..43f7d53 --- /dev/null +++ b/rules/phpstan-rules.neon @@ -0,0 +1,123 @@ +includes: + - ../../../vendor/phpstan/phpstan/conf/bleedingEdge.neon + - ../../../vendor/phpstan/phpstan-deprecation-rules/rules.neon +parameters: + ignoreErrors: + - '#Class (MDMysqliInvalidInput|MDMysqliExpectedError|MDExpectedException|MDgenericInvalidInputsException) is neither abstract nor final.#' + - '#Method MDMysqli::_check_query_efficiency\(\) is unused.#' + polluteScopeWithLoopInitialAssignments: false + polluteScopeWithAlwaysIterableForeach: false + checkAlwaysTrueCheckTypeFunctionCall: true + checkAlwaysTrueInstanceof: true + checkAlwaysTrueStrictComparison: true + checkExplicitMixedMissingReturn: true + checkFunctionNameCase: true + checkMissingClosureNativeReturnTypehintRule: true + reportMaybesInMethodSignatures: true + reportStaticMethodSignatures: true + ergebnis: + allowAbstractClasses: true + classesNotRequiredToBeAbstractOrFinal: [] + interfacesImplementedByContainers: + - Psr\Container\ContainerInterface + classesAllowedToBeExtended: + - mysqli + - mysqli_stmt + - Exception + - MDGenericWriter + - MDGenericObject + - XMLParser + - LidoParser + - MDValueSet + - MDMysqliInvalidInput + - MDMysqliExpectedError + - MDgenericInvalidInputsException + - MDExpectedException + +parametersSchema: + ergebnis: structure([ + allowAbstractClasses: bool() + classesAllowedToBeExtended: listOf(string()) + classesNotRequiredToBeAbstractOrFinal: listOf(string()) + interfacesImplementedByContainers: listOf(string()) + ]) + +rules: + - PHPStan\Rules\BooleansInConditions\BooleanInBooleanAndRule + - PHPStan\Rules\BooleansInConditions\BooleanInBooleanOrRule + - PHPStan\Rules\BooleansInConditions\BooleanInElseIfConditionRule + - PHPStan\Rules\BooleansInConditions\BooleanInTernaryOperatorRule + - PHPStan\Rules\DisallowedConstructs\DisallowedImplicitArrayCreationRule + - PHPStan\Rules\DisallowedConstructs\DisallowedShortTernaryRule + - PHPStan\Rules\ForeachLoop\OverwriteVariablesWithForeachRule + - PHPStan\Rules\Methods\WrongCaseOfInheritedMethodRule + - PHPStan\Rules\Operators\OperandInArithmeticPostDecrementRule + - PHPStan\Rules\Operators\OperandInArithmeticPostIncrementRule + - PHPStan\Rules\Operators\OperandInArithmeticPreDecrementRule + - PHPStan\Rules\Operators\OperandInArithmeticPreIncrementRule + - PHPStan\Rules\Operators\OperandsInArithmeticAdditionRule + - PHPStan\Rules\Operators\OperandsInArithmeticDivisionRule + - PHPStan\Rules\Operators\OperandsInArithmeticExponentiationRule + - PHPStan\Rules\Operators\OperandsInArithmeticModuloRule + - PHPStan\Rules\Operators\OperandsInArithmeticMultiplicationRule + - PHPStan\Rules\Operators\OperandsInArithmeticSubtractionRule + - PHPStan\Rules\StrictCalls\DynamicCallOnStaticMethodsRule + - PHPStan\Rules\StrictCalls\StrictFunctionCallsRule + - PHPStan\Rules\SwitchConditions\MatchingTypeInSwitchCaseConditionRule + - PHPStan\Rules\VariableVariables\VariableMethodCallRule + - PHPStan\Rules\VariableVariables\VariableStaticMethodCallRule + - PHPStan\Rules\VariableVariables\VariableStaticPropertyFetchRule + - PHPStan\Rules\VariableVariables\VariableVariablesRule + - Ergebnis\PHPStan\Rules\Closures\NoNullableReturnTypeDeclarationRule + - Ergebnis\PHPStan\Rules\Closures\NoParameterWithNullableTypeDeclarationRule + - Ergebnis\PHPStan\Rules\Expressions\NoCompactRule + - Ergebnis\PHPStan\Rules\Expressions\NoErrorSuppressionRule + - Ergebnis\PHPStan\Rules\Expressions\NoEvalRule + - Ergebnis\PHPStan\Rules\Files\DeclareStrictTypesRule + - Ergebnis\PHPStan\Rules\Functions\NoNullableReturnTypeDeclarationRule + - Ergebnis\PHPStan\Rules\Functions\NoParameterWithNullableTypeDeclarationRule + - Ergebnis\PHPStan\Rules\Functions\NoParameterWithNullDefaultValueRule + - Ergebnis\PHPStan\Rules\Methods\FinalInAbstractClassRule + - Ergebnis\PHPStan\Rules\Methods\NoNullableReturnTypeDeclarationRule + - Ergebnis\PHPStan\Rules\Methods\NoParameterWithNullableTypeDeclarationRule + - Ergebnis\PHPStan\Rules\Methods\NoParameterWithNullDefaultValueRule + - Ergebnis\PHPStan\Rules\Methods\PrivateInFinalClassRule + +services: + - + class: PHPStan\Rules\BooleansInConditions\BooleanRuleHelper + + - + class: PHPStan\Rules\Operators\OperatorRuleHelper + - + class: PHPStan\Rules\VariableVariables\VariablePropertyFetchRule + arguments: + universalObjectCratesClasses: %universalObjectCratesClasses% + tags: + - phpstan.rules.rule + - + class: Ergebnis\PHPStan\Rules\Classes\FinalRule + arguments: + allowAbstractClasses: %ergebnis.allowAbstractClasses% + classesNotRequiredToBeAbstractOrFinal: %ergebnis.classesNotRequiredToBeAbstractOrFinal% + tags: + - phpstan.rules.rule + + - + class: Ergebnis\PHPStan\Rules\Classes\NoExtendsRule + arguments: + classesAllowedToBeExtended: %ergebnis.classesAllowedToBeExtended% + tags: + - phpstan.rules.rule + + - + class: Ergebnis\PHPStan\Rules\Classes\PHPUnit\Framework\TestCaseWithSuffixRule + tags: + - phpstan.rules.rule + + - + class: Ergebnis\PHPStan\Rules\Methods\NoParameterWithContainerTypeDeclarationRule + arguments: + interfacesImplementedByContainers: %ergebnis.interfacesImplementedByContainers% + tags: + - phpstan.rules.rule