Git Product home page Git Product logo

Comments (4)

danielbachhuber avatar danielbachhuber commented on June 9, 2024 1

PHP doesn't offer any alternatives

I mean, there's foreach ( array_keys( $recipe_json ) as $key ), but I see your point. For large arrays that's another time through.

Ah, good point. Even so, I think this is one of those border areas (i.e. there's a reasonable explanation for an unused variable).

from phpcs-variable-analysis.

sirbrillig avatar sirbrillig commented on June 9, 2024

It should be the same, yes. If you set allowUnusedForeachVariables to true, then it will not be reported. But this does continue that discussion, specifically

we can consider if we want that option to be on by default

What do you think? It seems like there's an obvious benefit, but the reason I haven't enabled it by default already is that I haven't taken the time to examine the possible downsides. It definitely hides unused variables and I wonder if that's something that could be problematic for some code.

from phpcs-variable-analysis.

danielbachhuber avatar danielbachhuber commented on June 9, 2024

It'd make sense to me to enable allowUnusedForeachVariables by default because PHP doesn't offer any alternatives.

Similarly, I also had to enable allowUnusedCaughtExceptions.

from phpcs-variable-analysis.

sirbrillig avatar sirbrillig commented on June 9, 2024

PHP doesn't offer any alternatives

I mean, there's foreach ( array_keys( $recipe_json ) as $key ), but I see your point. For large arrays that's another time through.

Let me work up a PR and we'll see what that looks like.

Similarly, I also had to enable allowUnusedCaughtExceptions.

That's a good point and not one I've seen mentioned a lot, but it could probably help more people to have that on be default as well.

from phpcs-variable-analysis.

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.