Comments (2)
@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.
Closing for lack of response.
from phpcsextra.
Related Issues (20)
- Please add a sniff to format array key => value pairs HOT 1
- Question: what scenarios would using post inc/dec cause issues if code were moved around? HOT 3
- Add the unneeded ternary sniff HOT 1
- Sniff(s) to detect proper usage of preg_quote()
- Sniff to detect the irregular whitespace characters HOT 3
- Sniff to discourage "long" closures
- False positive in Universal.CodeAnalysis.ConstructorDestructorReturn HOT 3
- Incorrect detection of PHP 4-style constructors by Universal.CodeAnalysis.ConstructorDestructorReturn HOT 9
- Sniff to enforce naming conventions for namespace names
- Sniff to enforce naming conventions for class/function/const aliases
- Sniff to detect useless alias names HOT 1
- Sniff to flag `is_a()` and possibly replace with `instanceof`
- Ignore specific keys for Universal.Arrays.MixedArrayKeyTypes and Universal.Arrays.MixedKeyedUnkeyedArray HOT 9
- Add option to NormalizedArrays.Arrays.ArrayBraceSpacing to allow single- or multi-line empty arrays HOT 4
- preg_replace replacement with variable must be wrapped in addcslashes HOT 1
- Problem with NormalizedArrays.Arrays.CommaAfterLast in some cases HOT 7
- Feature suggestion: new sniff `EchoConcatenation`
- Potential new sniff: scan code for "Trojan source"
- Feature suggestion: new sniff for detecting brand name or text string HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from phpcsextra.