mimmi20/browser-detector

View on GitHub
phpstan.neon

Summary

Maintainability
Test Coverage
parameters:
  level: max

  parallel:
    maximumNumberOfProcesses: 1
    processTimeout: 200.0

  paths:
    - src
    - tests

  scanFiles:
    - %currentWorkingDirectory%/vendor/autoload.php
    - %currentWorkingDirectory%/vendor/squizlabs/php_codesniffer/autoload.php
    - %currentWorkingDirectory%/vendor/squizlabs/php_codesniffer/src/Util/Tokens.php

  # reports occurrences of type-checking functions always evaluated to true
  checkAlwaysTrueCheckTypeFunctionCall: false # todo: fix

  # reports instanceof occurrences always evaluated to true
  checkAlwaysTrueInstanceof: false # todo: fix

  # reports === and !== occurrences always evaluated to true
  checkAlwaysTrueStrictComparison: true

  # enable stricter analysis of benevolent union types
  checkBenevolentUnionTypes: true

  # reports use of dynamic properties as undefined
  checkDynamicProperties: true

  # reports code paths with missing return statement in functions and methods with @return mixed PHPDoc
  checkExplicitMixedMissingReturn: true

  # reports function and method calls with incorrect name case
  checkFunctionNameCase: true

  # be strict about values with an unspecified (implicit mixed) type
  checkImplicitMixed: true

  # reports references to built-in classes with incorrect name case
  checkInternalClassCaseSensitivity: true

  # require that callable signatures are specified
  checkMissingCallableSignature: true

  # checks for missing typehints in iterables
  checkMissingIterableValueType: true

  # reports return typehints that could be narrowed down because some of the listed types are never returned
  checkTooWideReturnTypesInProtectedAndPublicMethods: true

  # reports properties with native types that weren’t initialized in the class constructor
  checkUninitializedProperties: true

  # reports missing #[\Override] attribute
  checkMissingOverrideMethodAttribute: true

  # doesn’t require typehints for properties if the types can be inferred from constructor injection
  inferPrivatePropertyTypeFromConstructor: false

  # prevents reading key and value variables set in foreach when iterating over a non-empty array
  polluteScopeWithAlwaysIterableForeach: false

  # prevents reading variables set in for loop initial statement and while loop condition after the loop
  polluteScopeWithLoopInitialAssignments: false

  # report always true last condition in a series of elseif branches and match expression arms
  reportAlwaysTrueInLastCondition: true

  # reports violations of parameter type contravariance and return type covariance
  reportMaybesInMethodSignatures: false # todo: fix

  # reports violations of property type invariance
  reportMaybesInPropertyPhpDocTypes: true

  # reports violations of parameter type contravariance and return type covariance in static methods
  reportStaticMethodSignatures: true

  #
  reportWrongPhpDocTypeInVarTag: true

  # differentiate between PHPDoc and native types (if false)
  treatPhpDocTypesAsCertain: false

  tipsOfTheDay: false

  exceptions:
    implicitThrows: false
    checkedExceptionRegexes:
      - '#Exception#'
      - '#Throwable#'
    check:
      missingCheckedExceptionInThrows: true
      tooWideThrowType: true

  cognitive_complexity:
    class: 43
    function: 43

  type_coverage:
    return: 100
    param: 99.8
    property: 100
    # also, how many files has declare strict types
    declare: 100

  unused_public:
    methods: true
    properties: true
    constants: true
    local_methods: true

  type_perfect:
    null_over_false: true
    no_mixed: true
    narrow_param: true

  ignoreErrors:
    - '~, array given~'
    - '~Public (constant|method) ".*" is never used~'
#    -
#      message: '~is never read, only written~'
#      path: src/Detector.php
    -
      message: '~Parameter #1 \$request of method BrowserDetector\\RequestBuilder::buildRequest\(\) expects array<non-empty-string, non-empty-string>~'
      path: tests/DetectorTest/RequestBuilderTest.php

rules:
  # code complexity
  # - Symplify\PHPStanRules\Rules\NoDynamicNameRule
  # - Symplify\PHPStanRules\Rules\NoReturnArrayVariableListRule # todo: fix

  - Symplify\PHPStanRules\Rules\ForbiddenExtendOfNonAbstractClassRule

  # domain
  # - Symplify\PHPStanRules\Rules\Domain\RequireExceptionNamespaceRule
  - Symplify\PHPStanRules\Rules\Domain\RequireAttributeNamespaceRule
  - Symplify\PHPStanRules\Rules\Enum\RequireUniqueEnumConstantRule
  - Symplify\PHPStanRules\Rules\PreventParentMethodVisibilityOverrideRule

  # paths
  # - Symplify\PHPStanRules\Rules\NoReferenceRule # References are required

  # explicit naming
  - Symplify\PHPStanRules\Rules\ForbiddenMultipleClassLikeInOneFileRule

  - Symplify\PHPStanRules\Rules\Complexity\ForbiddenArrayMethodCallRule
  # - Symplify\PHPStanRules\Rules\CheckRequiredInterfaceInContractNamespaceRule

  # naming
  - Symplify\PHPStanRules\Rules\RequireAttributeNameRule

  # regexes
  - Symplify\PHPStanRules\Rules\AnnotateRegexClassConstWithRegexLinkRule
  # - Symplify\PHPStanRules\Rules\NoInlineStringRegexRule # todo fix
  - Symplify\PHPStanRules\Rules\RegexSuffixInRegexConstantRule

  # naming
  - Symplify\PHPStanRules\Rules\Explicit\ExplicitClassPrefixSuffixRule
  # - Symplify\PHPStanRules\Rules\NoReturnSetterMethodRule
  - Symplify\PHPStanRules\Rules\UppercaseConstantRule
  - Symplify\PHPStanRules\Rules\ClassNameRespectsParentSuffixRule
  - Symplify\PHPStanRules\Rules\CheckClassNamespaceFollowPsr4Rule