Code Monkey home page Code Monkey logo

Comments (2)

jrfnl avatar jrfnl commented on July 21, 2024

@kkmuffme That is not what this sniff is about. This sniff flags arrays with items which result in a mix of numeric and string keys. The sniff has no opinion on what type of keys the array should have. It only demands that the key type of the array is consistent: either all numeric keys, whether implicitly/explicitly set, or all string keys.

An array like the below will, for instance, not be flagged by this sniff as all items will end up having an integer key:

$array = array(
    'a',
    2 => 'b',
    '3' => 'c',
    4 => 'd',
);

often the string key can be removed completely, instead of adding an explicit key for the majority of array elements.

That is a perfectly valid way to solve the error this sniff throws, but it is not for this sniff to have an opinion on whether that is the preferred way to solve the error.

This feature request seems to be more closely related to the MixedKeyedUnkeyedArray sniff which demands that all array items have either an explicit key or an implicit key, but flags arrays which have a mix of both.

from phpcsextra.

jrfnl avatar jrfnl commented on July 21, 2024

Closing for lack of response.

from phpcsextra.

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.