Giter Site home page Giter Site logo

Comments (4)

ondrejmirtes avatar ondrejmirtes commented on May 9, 2024

No idea what you're talking about, can you provide an example?

from phpstan-nette.

staabm avatar staabm commented on May 9, 2024

a project which references class from a different package in a .neon file like e.g.

services:
    -
        class: Symplify\PHPStanRules\CognitiveComplexity\Rules\FunctionLikeCognitiveComplexityRule
        tags: [phpstan.rules.rule]
        arguments:
            maxMethodCognitiveComplexity: 8

would be interessted whether the class Symplify\PHPStanRules\CognitiveComplexity\Rules\FunctionLikeCognitiveComplexityRule is considered deprecated and might go away in a future release (or a alternative should be used).

when such file is only referenced in .neon files, noone see a error otherwise anywhere.

from phpstan-nette.

ondrejmirtes avatar ondrejmirtes commented on May 9, 2024

I know that people tend to do this and PHPStan more or less supports it, but the package author isn't free to change constructor arguments and add/remove/rename the classes. I'm careful with this in PHPStan itself but I don't want to ask this of other authors.

The longterm solution isn't to include rules in custom configs like this but instead take advantage of error identifiers (phpstan/phpstan#3065) to include/exclude rules in config.

Right now your only correct option is to use the whole package and ignore errors based on regexes in ignoreErrors.

Another option is to contribute/ask for separate config parameter that would be used in conditionalTags section like this:

parameters:
    symplify:
        functionLikeCognitiveComplexity: true

parametersSchema:
    symplify:
        structure([
            functionLikeCognitiveComplexity: bool()
        ])

conditionalTags:
    Symplify\PHPStanRules\CognitiveComplexity\Rules\FunctionLikeCognitiveComplexityRule:
        phpstan.rules.rule: %symplify.functionLikeCognitiveComplexity%

services:
    -
        class: Symplify\PHPStanRules\CognitiveComplexity\Rules\FunctionLikeCognitiveComplexityRule
        arguments:
            maxMethodCognitiveComplexity: 8

(FYI I'd welcome these parameters in phpstan-strict-rules too.)

That way you'd be able to turn off this rule with these lines in your phpstan.neon:

parameters:
    symplify:
        functionLikeCognitiveComplexity: false

Another nice benefit is that you'd be able to use phpstan/extension-installer even if you don't want to use everyhing a package offers.

But if you include rule classes in your config like this I think it's right to expect it can break from time to time.

from phpstan-nette.

github-actions avatar github-actions commented on May 9, 2024

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

from phpstan-nette.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.