Releases: Moxio/php-codesniffer-sniffs
2.5.0
2.4.0
2.3.0
New sniff added: MoxioSniffs.PHP.DisallowUtf8EncodeDecode. This sniff disallows calls to utf8_encode() and utf8_decode(). These functions can be considered misleading because they only convert to/from ISO-8859-1, and do not 'magically' detect the source/target encoding. Using iconv() or mb_convert_encoding() instead makes both character encodings that play a role in the conversion explicit.
2.2.0
This project now requires PHP 7.1 or newer.
New sniff added: MoxioSniffs.PHP.DisallowMbDetectEncoding, which disallows usage of mb_detect_encoding. This function has a misleading name that implies it can actually detect the encoding of a string, a problem which is generally impossible. Rather it checks a list of encodings until it finds one that could be the right one (i.e. the string is a valid byte sequence according to that encoding). Using mb_check_encoding (possibly in a loop) instead makes this much more explicit. See this talk for more background information on this topic.
2.1.0
New sniff added: MoxioSniffs.PHP.DisallowDateTime: This sniff disallows usage of \DateTime and promotes the use of \DateTimeImmutable instead. The former being mutable can lead to some subtle but nasty bugs. Thanks to @nikolaposa for the blogpost that inspired this sniff, and to the folks at @slevomat for their great collection of helpers for PHP_CodeSniffer.
2.0.0
This major release contains a backward incompatible change to the 'standard' name (Moxio to MoxioSniffs) and associated namespace (Moxio\Sniffs to Moxio\CodeSniffer\MoxioSniffs\Sniffs). This change is meant to emphasize the character of this 'standard' as a set of pick-and-match sniffs rather than a complete coding standard, and to prevent naming conflicts with our internal company coding standard. Please consult the upgrading instructions.
1.6.0
New sniff added: Moxio.PHP.DisallowImplicitIteratorToArrayWithUseKeys. This sniff disallows calls to iterator_to_array() without the $use_keys argument being explicitly set. By default, iterator_to_array uses the keys provided by the iterator. This behavior is often desired for associative arrays, but can cause unexpected results for 'list-like' arrays. Explicitly requiring the parameter to be set ensures that the developer has to think about which behavior is desired for the situation at hand. Thanks to @hollodotme for drawing our attention to this 'risky' default behavior.
1.5.0
New sniff added: Moxio.PHP.DisallowImplicitLooseBase64Decode. This sniff disallows implicit non-strict usage of the base64_decode function. By default, this function silently discards invalid characters, which may be unexpected and undesirable. Using this sniff, one needs to explicitly opt-in to this behavior, making it a deliberate choice. Thank you @dheineman for this contribution (#5).
1.4.1
This project is now automatically detected by DealerDirect/phpcodesniffer-composer-installer, so that (if that plugin is used) PHP_CodeSniffer can reference the standard by name. Thank you @dheineman for the PR (#4)!
1.4.0
Changed Moxio.PHP.ImplicitLooseComparisonSniff to also apply to array_keys. When called with two or more parameters, array_keys essentially behaves like a multi-valued array_search. For that variant, we now also disallow implicit loose comparisons, like we also already do for array_search. Calls to array_keys with just a single parameter (i.e. without $search_value) are unaffected.